fix all eslint errors
This commit is contained in:
@@ -3,9 +3,9 @@ import { t } from "@/config/i18n";
|
||||
import { DatePickerInput } from "@mantine/dates";
|
||||
import { IconCancel } from "@tabler/icons-react";
|
||||
import { useForm } from "@mantine/form";
|
||||
import { useEffect, useMemo } from "react";
|
||||
import { shipmentToShipmentInputs, type Shipment, type ShipmentInputs } from "@/services/resources/shipments";
|
||||
import { getForms, getProductors, getProducts } from "@/services/api";
|
||||
import { useMemo } from "react";
|
||||
import { type Shipment, type ShipmentInputs } from "@/services/resources/shipments";
|
||||
import { useGetForms, useGetProductors, useGetProducts } from "@/services/api";
|
||||
|
||||
export type ShipmentModalProps = ModalBaseProps & {
|
||||
currentShipment?: Shipment;
|
||||
@@ -20,10 +20,10 @@ export default function ShipmentModal({
|
||||
}: ShipmentModalProps) {
|
||||
const form = useForm<ShipmentInputs>({
|
||||
initialValues: {
|
||||
name: "",
|
||||
date: null,
|
||||
form_id: "",
|
||||
product_ids: []
|
||||
name: currentShipment?.name ?? "",
|
||||
date: currentShipment?.date ?? null,
|
||||
form_id: currentShipment ? String(currentShipment?.form_id) : "",
|
||||
product_ids: currentShipment?.products.map((el) => (String(el.id))) ?? []
|
||||
},
|
||||
validate: {
|
||||
name: (value) =>
|
||||
@@ -35,18 +35,12 @@ export default function ShipmentModal({
|
||||
}
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (currentShipment) {
|
||||
form.setValues(shipmentToShipmentInputs(currentShipment));
|
||||
}
|
||||
}, [currentShipment]);
|
||||
const { data: allForms } = useGetForms();
|
||||
const { data: allProducts } = useGetProducts(new URLSearchParams("types=1"));
|
||||
const { data: allProductors } = useGetProductors()
|
||||
|
||||
const { data: allForms } = getForms();
|
||||
const { data: allProducts } = getProducts(new URLSearchParams("types=1"));
|
||||
const { data: allProductors } = getProductors()
|
||||
|
||||
const formsSelect = useMemo(() => {
|
||||
return allForms?.map(form => ({value: String(form.id), label: `${form.name} ${form.season}`}))
|
||||
return allForms?.map(currentForm => ({value: String(currentForm.id), label: `${currentForm.name} ${currentForm.season}`}))
|
||||
}, [allForms]);
|
||||
|
||||
const productsSelect = useMemo(() => {
|
||||
@@ -60,7 +54,7 @@ export default function ShipmentModal({
|
||||
.map((product) => ({value: String(product.id), label: `${product.name}`}))
|
||||
}
|
||||
});
|
||||
}, [allProducts, form]);
|
||||
}, [allProductors, allProducts]);
|
||||
|
||||
return (
|
||||
<Modal
|
||||
|
||||
Reference in New Issue
Block a user