import { Input, Modal, Form as FormAnt, Select, Upload } from "antd"; import { updateController } from "../../API/LayoutApi/update"; import { useState } from "react"; import fileUpload from "../../assets/upload-file.png"; import { useCompanyData } from "../../Hooks/Companies"; import { useCustomerByComanyData } from "../../Hooks/Customers"; import { QueryObserverResult, RefetchOptions, RefetchQueryFilters, } from "react-query"; import { TUpdate } from "../../types/Update/TUpdate"; import TextArea from "antd/es/input/TextArea"; const { Option } = Select; const AddUpdate = ({ refetch, open, setOpen, }: { refetch: ( options?: (RefetchOptions & RefetchQueryFilters) | undefined ) => Promise>; open: boolean; setOpen(open: boolean): void; }) => { const [form] = FormAnt.useForm(); const handleCancel = () => { refetch(); setOpen(!open); }; const [companyName, setCompanyName] = useState(""); const [customerName, setCustomerName] = useState(""); const [companyId, setCompanyId] = useState(); const companyData = useCompanyData({ name: companyName }); const customerData = useCustomerByComanyData( { name: customerName, page: 1, page_size: 10, }, companyId ); function handlePaste(event: any) { const clipboardData = event.clipboardData || window.Clipboard; if (clipboardData && clipboardData.items.length > 0) { const clipboardItem = clipboardData.items[0]; if (clipboardItem.kind === "file") { const file = clipboardItem.getAsFile(); const formData = new FormData(); formData.append("file", file); // taskController.addTaskFile(formData).then((response) => { // const fileId = response.id; // const n = [response.file]; // setImgname((prev: any) => [...prev, ...n]); // setFileIds((prevFileIds): any => [...prevFileIds, fileId]); // const updatedValues = form.getFieldsValue(); // updatedValues.attachment_ids = [ // ...updatedValues.attachment_ids, // fileId, // ]; // form.setFieldsValue(updatedValues); // }); } } } return (
handlePaste(event)}> { form.validateFields().then(async (values) => { const updatedValues = { ...values }; form.resetFields(); await updateController.addUpdateController(updatedValues); setOpen(!open); refetch(); }); }} > setCustomerName(value)} options={customerData?.data?.data?.map((item) => ({ label: item?.name, value: item?.id, }))} value={customerName} filterOption={false} autoClearSearchValue={false} allowClear />
{/* */}