Unexpected any
This commit is contained in:
parent
8b6175eb71
commit
19b7b51bd7
@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import ReactSelect, { SingleValue } from "react-select";
|
||||
|
||||
interface OptionType {
|
||||
export interface OptionType {
|
||||
value: string | number;
|
||||
label: string;
|
||||
}
|
||||
@ -14,7 +14,6 @@ interface SelectProps {
|
||||
name: string;
|
||||
}
|
||||
|
||||
|
||||
export function Select({options, placeholder, value, onChange, name}: SelectProps) {
|
||||
return (
|
||||
<>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import {Input} from "@/components/Input/Input";
|
||||
import {useState} from "react";
|
||||
import React, {useState} from "react";
|
||||
import Button from "@/components/Button/Button";
|
||||
import {add, update} from "@/api/bodyTypes";
|
||||
import {useModalContext} from "@/components/Modal/ModalContext";
|
||||
@ -14,7 +14,7 @@ export default function BodyType({ initialData }: any) {
|
||||
name: initialData?.name || "",
|
||||
});
|
||||
|
||||
const handleChange = (e: any) => {
|
||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const { name, value } = e.target;
|
||||
setFormData({
|
||||
...formData,
|
||||
|
||||
@ -1,15 +1,16 @@
|
||||
import Button from "@/components/Button/Button";
|
||||
import React, {useState} from "react";
|
||||
import {useCarModelContext} from "@/api/context/CarModel";
|
||||
import {useEngineContext} from "@/api/context/Engine";
|
||||
import {useTrimContext} from "@/api/context/Trim";
|
||||
import {useBodyTypeContext} from "@/api/context/BodyType";
|
||||
import {useCarColorContext} from "@/api/context/CarColor";
|
||||
import {useTransmissionContext} from "@/api/context/Transmission";
|
||||
import {Select} from "@/components/Select/Select";
|
||||
import {CarModelItem, useCarModelContext} from "@/api/context/CarModel";
|
||||
import {EngineItem, useEngineContext} from "@/api/context/Engine";
|
||||
import {TrimItem, useTrimContext} from "@/api/context/Trim";
|
||||
import {BodyTypeItem, useBodyTypeContext} from "@/api/context/BodyType";
|
||||
import {CarColorItem, useCarColorContext} from "@/api/context/CarColor";
|
||||
import {TransmissionItem, useTransmissionContext} from "@/api/context/Transmission";
|
||||
import {OptionType, Select} from "@/components/Select/Select";
|
||||
import {useModalContext} from "@/components/Modal/ModalContext";
|
||||
import {add, update} from "@/api/cars";
|
||||
import {useCarContext} from "@/api/context/Car";
|
||||
import {SingleValue} from "react-select";
|
||||
|
||||
export default function Car({ initialData }: any) {
|
||||
const { carModel } = useCarModelContext();
|
||||
@ -21,32 +22,32 @@ export default function Car({ initialData }: any) {
|
||||
const { fetchData } = useCarContext();
|
||||
const { setContentModal } = useModalContext();
|
||||
|
||||
const carModelOptions = carModel?.map((model: any) => ({
|
||||
const carModelOptions = carModel?.map((model: CarModelItem) => ({
|
||||
value: model.id,
|
||||
label: model.name
|
||||
})) || [];
|
||||
|
||||
const engineOptions = engine?.map((engine: any) => ({
|
||||
const engineOptions = engine?.map((engine: EngineItem) => ({
|
||||
value: engine.id,
|
||||
label: engine.type
|
||||
})) || [];
|
||||
|
||||
const trimOptions = trim?.map((trim: any) => ({
|
||||
const trimOptions = trim?.map((trim: TrimItem) => ({
|
||||
value: trim.id,
|
||||
label: trim.name
|
||||
})) || [];
|
||||
|
||||
const bodyTypesOptions = bodyTypes?.map((bodyType: any) => ({
|
||||
const bodyTypesOptions = bodyTypes?.map((bodyType: BodyTypeItem) => ({
|
||||
value: bodyType.id,
|
||||
label: bodyType.name
|
||||
})) || [];
|
||||
|
||||
const carColorOptions = carColor?.map((color: any) => ({
|
||||
const carColorOptions = carColor?.map((color: CarColorItem) => ({
|
||||
value: color.id,
|
||||
label: color.name
|
||||
})) || [];
|
||||
|
||||
const transmissionOptions = transmission?.map((transmission: any) => ({
|
||||
const transmissionOptions = transmission?.map((transmission: TransmissionItem) => ({
|
||||
value: transmission.id,
|
||||
label: transmission.type
|
||||
})) || [];
|
||||
@ -76,61 +77,55 @@ export default function Car({ initialData }: any) {
|
||||
<Select options={carModelOptions}
|
||||
placeholder={"Модель автомобиля"}
|
||||
value={formData.car_models_id}
|
||||
onChange={(e: any) => {
|
||||
const { value } = e;
|
||||
onChange={(e: SingleValue<OptionType>) => {
|
||||
setFormData({
|
||||
...formData,
|
||||
car_models_id: value
|
||||
car_models_id: e ? e.value : null,
|
||||
});
|
||||
}} name="car_models_id"/>
|
||||
<Select options={engineOptions}
|
||||
placeholder={"Двигатель"}
|
||||
value={formData.engines_id}
|
||||
onChange={(e: any) => {
|
||||
const { value } = e;
|
||||
onChange={(e: SingleValue<OptionType>) => {
|
||||
setFormData({
|
||||
...formData,
|
||||
engines_id: value
|
||||
engines_id: e ? e.value : null,
|
||||
});
|
||||
}} name="engines_id"/>
|
||||
<Select options={trimOptions}
|
||||
placeholder={"Комплектация"}
|
||||
value={formData.trims_id}
|
||||
onChange={(e: any) => {
|
||||
const { value } = e;
|
||||
onChange={(e: SingleValue<OptionType>) => {
|
||||
setFormData({
|
||||
...formData,
|
||||
trims_id: value
|
||||
trims_id: e ? e.value : null,
|
||||
});
|
||||
}} name="trims_id"/>
|
||||
<Select options={bodyTypesOptions}
|
||||
placeholder={"Тип кузова"}
|
||||
value={formData.body_types_id}
|
||||
onChange={(e: any) => {
|
||||
const { value } = e;
|
||||
onChange={(e: SingleValue<OptionType>) => {
|
||||
setFormData({
|
||||
...formData,
|
||||
body_types_id: value
|
||||
body_types_id: e ? e.value : null,
|
||||
});
|
||||
}} name="body_types_id"/>
|
||||
<Select options={carColorOptions}
|
||||
placeholder={"Цвет автомобиля"}
|
||||
value={formData.car_colors_id}
|
||||
onChange={(e: any) => {
|
||||
const { value } = e;
|
||||
onChange={(e: SingleValue<OptionType>) => {
|
||||
setFormData({
|
||||
...formData,
|
||||
car_colors_id: value
|
||||
car_colors_id: e ? e.value : null,
|
||||
});
|
||||
}} name="car_colors_id"/>
|
||||
<Select options={transmissionOptions}
|
||||
placeholder={"Трансмиссия"}
|
||||
value={formData.transmissions_id}
|
||||
onChange={(e: any) => {
|
||||
const { value } = e;
|
||||
onChange={(e: SingleValue<OptionType>) => {
|
||||
setFormData({
|
||||
...formData,
|
||||
transmissions_id: value
|
||||
transmissions_id: e ? e.value : null,
|
||||
});
|
||||
}} name="transmissions_id"/>
|
||||
<Button onClickAction={handleSubmit}>Сохранить</Button>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import {Input} from "@/components/Input/Input";
|
||||
import {useState} from "react";
|
||||
import React, {useState} from "react";
|
||||
import Button from "@/components/Button/Button";
|
||||
import {useModalContext} from "@/components/Modal/ModalContext";
|
||||
import {useCarBrandContext} from "@/api/context/CarBrand";
|
||||
@ -15,7 +15,7 @@ export default function CarBrand({ initialData }: any) {
|
||||
country: initialData?.country || "",
|
||||
});
|
||||
|
||||
const handleChange = (e: any) => {
|
||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const { name, value } = e.target;
|
||||
setFormData({
|
||||
...formData,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useState } from "react";
|
||||
import React, { useState } from "react";
|
||||
import {InputColor} from "@/components/Input/InputColor";
|
||||
import {Input} from "@/components/Input/Input";
|
||||
import Button from "@/components/Button/Button";
|
||||
@ -16,7 +16,7 @@ export default function CarColor({ initialData }: any) {
|
||||
hexCode: initialData?.hexCode || "#000000",
|
||||
});
|
||||
|
||||
const handleChange = (e: any) => {
|
||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const { name, value } = e.target;
|
||||
setFormData({
|
||||
...formData,
|
||||
|
||||
@ -2,10 +2,11 @@ import {Input} from "@/components/Input/Input";
|
||||
import React, {useState} from "react";
|
||||
import Button from "@/components/Button/Button";
|
||||
import {useCarBrandContext} from "@/api/context/CarBrand";
|
||||
import {Select} from "@/components/Select/Select";
|
||||
import {OptionType, Select} from "@/components/Select/Select";
|
||||
import {add, update} from "@/api/carModels";
|
||||
import {useCarModelContext} from "@/api/context/CarModel";
|
||||
import {useModalContext} from "@/components/Modal/ModalContext";
|
||||
import {SingleValue} from "react-select";
|
||||
|
||||
export default function CarModel({ initialData }: any) {
|
||||
const { setContentModal } = useModalContext();
|
||||
@ -25,7 +26,7 @@ export default function CarModel({ initialData }: any) {
|
||||
car_brands_id: initialData?.car_brands_id || null,
|
||||
});
|
||||
|
||||
const handleChange = (e: any) => {
|
||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const { name, value } = e.target;
|
||||
setFormDataCarModel({
|
||||
...formDataCarModel,
|
||||
@ -33,11 +34,10 @@ export default function CarModel({ initialData }: any) {
|
||||
});
|
||||
};
|
||||
|
||||
const handleChangeSelect = (e: any) => {
|
||||
const { value } = e;
|
||||
const handleChangeSelect = (e: SingleValue<OptionType>) => {
|
||||
setFormDataCarModel({
|
||||
...formDataCarModel,
|
||||
car_brands_id: value
|
||||
car_brands_id: e ? e.value : null
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import {Input} from "@/components/Input/Input";
|
||||
import {useState} from "react";
|
||||
import React, {useState} from "react";
|
||||
import Button from "@/components/Button/Button";
|
||||
import {useModalContext} from "@/components/Modal/ModalContext";
|
||||
import {add, update} from "@/api/customers";
|
||||
@ -16,7 +16,7 @@ export default function Customer({ initialData }: any) {
|
||||
email: initialData?.email || "",
|
||||
});
|
||||
|
||||
const handleChange = (e: any) => {
|
||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const { name, value } = e.target;
|
||||
setFormData({
|
||||
...formData,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import {Input} from "@/components/Input/Input";
|
||||
import {useState} from "react";
|
||||
import React, {useState} from "react";
|
||||
import Button from "@/components/Button/Button";
|
||||
import {useEngineContext} from "@/api/context/Engine";
|
||||
import {add, update} from "@/api/engines";
|
||||
@ -16,7 +16,7 @@ export default function Engine({ initialData }: any) {
|
||||
volume: initialData?.volume || "",
|
||||
});
|
||||
|
||||
const handleChange = (e: any) => {
|
||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const { name, value } = e.target;
|
||||
setFormData({
|
||||
...formData,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import Button from "@/components/Button/Button";
|
||||
import {useModalContext} from "@/components/Modal/ModalContext";
|
||||
import {Select} from "@/components/Select/Select";
|
||||
import {OptionType, Select} from "@/components/Select/Select";
|
||||
import React, {useState} from "react";
|
||||
import {add, update} from "@/api/sales";
|
||||
import {useSaleContext} from "@/api/context/Sale";
|
||||
@ -8,6 +8,7 @@ import {Input} from "@/components/Input/Input";
|
||||
import {useCarContext} from "@/api/context/Car";
|
||||
import {useCustomerContext} from "@/api/context/Customer";
|
||||
import {InputDate} from "@/components/Input/InputDate";
|
||||
import {SingleValue} from "react-select";
|
||||
|
||||
export default function Sale({ initialData }:any) {
|
||||
const { setContentModal } = useModalContext();
|
||||
@ -34,7 +35,7 @@ export default function Sale({ initialData }:any) {
|
||||
customers_id: initialData?.customers_id || null,
|
||||
});
|
||||
|
||||
const handleChange = (e: any) => {
|
||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const { name, value } = e.target;
|
||||
setFormData({
|
||||
...formData,
|
||||
@ -59,21 +60,19 @@ export default function Sale({ initialData }:any) {
|
||||
<Select options={carOptions}
|
||||
placeholder={"Автомобиль"}
|
||||
value={formData.cars_id}
|
||||
onChange={(e: any) => {
|
||||
const { value } = e;
|
||||
onChange={(e: SingleValue<OptionType>) => {
|
||||
setFormData({
|
||||
...formData,
|
||||
cars_id: value
|
||||
cars_id: e ? e.value : null
|
||||
});
|
||||
}} name="cars_id"/>
|
||||
<Select options={customersOptions}
|
||||
placeholder={"Покупатель"}
|
||||
value={formData.customers_id}
|
||||
onChange={(e: any) => {
|
||||
const { value } = e;
|
||||
onChange={(e: SingleValue<OptionType>) => {
|
||||
setFormData({
|
||||
...formData,
|
||||
customers_id: value
|
||||
customers_id: e ? e.value : null
|
||||
});
|
||||
}} name="customers_id"/>
|
||||
<Button onClickAction={handleSubmit}>Сохранить</Button>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import {Input} from "@/components/Input/Input";
|
||||
import {useState} from "react";
|
||||
import React, {useState} from "react";
|
||||
import Button from "@/components/Button/Button";
|
||||
import {add, update} from "@/api/transmissions";
|
||||
import {useModalContext} from "@/components/Modal/ModalContext";
|
||||
@ -14,7 +14,7 @@ export default function Transmission({ initialData }: any) {
|
||||
type: initialData?.type || "",
|
||||
});
|
||||
|
||||
const handleChange = (e: any) => {
|
||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const { name, value } = e.target;
|
||||
setFormData({
|
||||
...formData,
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
import {Input} from "@/components/Input/Input";
|
||||
import React, {useState} from "react";
|
||||
import Button from "@/components/Button/Button";
|
||||
import {Select} from "@/components/Select/Select";
|
||||
import {OptionType, Select} from "@/components/Select/Select";
|
||||
import {useCarModelContext} from "@/api/context/CarModel";
|
||||
import {add, update} from "@/api/trims";
|
||||
import {useModalContext} from "@/components/Modal/ModalContext";
|
||||
import {useTrimContext} from "@/api/context/Trim";
|
||||
import {SingleValue} from "react-select";
|
||||
|
||||
export default function Trim({ initialData }: any) {
|
||||
const { carModel } = useCarModelContext();
|
||||
@ -24,7 +25,7 @@ export default function Trim({ initialData }: any) {
|
||||
car_models_id: initialData?.car_models_id || null,
|
||||
});
|
||||
|
||||
const handleChange = (e: any) => {
|
||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const { name, value } = e.target;
|
||||
setFormData({
|
||||
...formData,
|
||||
@ -32,11 +33,10 @@ export default function Trim({ initialData }: any) {
|
||||
});
|
||||
};
|
||||
|
||||
const handleChangeSelect = (e: any) => {
|
||||
const { value } = e;
|
||||
const handleChangeSelect = (e: SingleValue<OptionType>) => {
|
||||
setFormData({
|
||||
...formData,
|
||||
car_models_id: value
|
||||
car_models_id: e ? e.value : null
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user