|
|
|
@ -40,6 +40,7 @@ import { companyController } from "../../API/LayoutApi/companies";
|
|
|
|
import { TCompany } from "../../types/Company/TCompany";
|
|
|
|
import { TCompany } from "../../types/Company/TCompany";
|
|
|
|
import { customerController } from "../../API/LayoutApi/customers";
|
|
|
|
import { customerController } from "../../API/LayoutApi/customers";
|
|
|
|
import { TCustomer } from "../../types/Customer/TCustomer";
|
|
|
|
import { TCustomer } from "../../types/Customer/TCustomer";
|
|
|
|
|
|
|
|
import { useCreateTask } from "../../Hooks/Tasks";
|
|
|
|
|
|
|
|
|
|
|
|
const { Option } = Select;
|
|
|
|
const { Option } = Select;
|
|
|
|
const AddTask = ({
|
|
|
|
const AddTask = ({
|
|
|
|
@ -120,7 +121,7 @@ const AddTask = ({
|
|
|
|
page: 1,
|
|
|
|
page: 1,
|
|
|
|
page_size: 5,
|
|
|
|
page_size: 5,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
companyId
|
|
|
|
companyId,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.then((data) => {
|
|
|
|
.then((data) => {
|
|
|
|
setCustomerData(data.data);
|
|
|
|
setCustomerData(data.data);
|
|
|
|
@ -210,20 +211,49 @@ const AddTask = ({
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const createTaskMutation = useCreateTask();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// const handleSubmit = (values: any) => {
|
|
|
|
|
|
|
|
// if (createTaskMutation.isLoading) return; // 🔒 double submit block
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// const payload = {
|
|
|
|
|
|
|
|
// ...values,
|
|
|
|
|
|
|
|
// attachment_ids: fileIds,
|
|
|
|
|
|
|
|
// note:
|
|
|
|
|
|
|
|
// (text ? text + ", " : "") +
|
|
|
|
|
|
|
|
// (note ? note + ", " : "") +
|
|
|
|
|
|
|
|
// (note2 ? note2 + ", " : ""),
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// createTaskMutation.mutate(payload, {
|
|
|
|
|
|
|
|
// onSuccess: () => {
|
|
|
|
|
|
|
|
// form.resetFields();
|
|
|
|
|
|
|
|
// setOpen(false);
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// onError: (error) => {
|
|
|
|
|
|
|
|
// console.error(error);
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
const handleSubmit = async (values: any) => {
|
|
|
|
const handleSubmit = async (values: any) => {
|
|
|
|
|
|
|
|
if (createTaskMutation.isLoading) return;
|
|
|
|
|
|
|
|
|
|
|
|
values.attachment_ids = fileIds;
|
|
|
|
values.attachment_ids = fileIds;
|
|
|
|
values.note =
|
|
|
|
values.note =
|
|
|
|
(text ? text + ", " : "") +
|
|
|
|
(text ? text + ", " : "") +
|
|
|
|
(note ? note + ", " : "") +
|
|
|
|
(note ? note + ", " : "") +
|
|
|
|
(note2 ? note2 + ", " : "");
|
|
|
|
(note2 ? note2 + ", " : "");
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
createTaskMutation.mutate(values, {
|
|
|
|
await taskController.addTaskController(values);
|
|
|
|
onSuccess: () => {
|
|
|
|
form.resetFields();
|
|
|
|
form.resetFields();
|
|
|
|
setOpen(false);
|
|
|
|
setOpen(false);
|
|
|
|
} catch (error) {
|
|
|
|
},
|
|
|
|
console.error(error);
|
|
|
|
onError: (error) => {
|
|
|
|
}
|
|
|
|
console.error(error);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
@ -252,12 +282,17 @@ const AddTask = ({
|
|
|
|
okText="Create"
|
|
|
|
okText="Create"
|
|
|
|
cancelText="Cancel"
|
|
|
|
cancelText="Cancel"
|
|
|
|
onCancel={() => {
|
|
|
|
onCancel={() => {
|
|
|
|
|
|
|
|
if (createTaskMutation.isLoading) return;
|
|
|
|
form.resetFields();
|
|
|
|
form.resetFields();
|
|
|
|
setOpen(false);
|
|
|
|
setOpen(false);
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
onOk={() => form.submit()}
|
|
|
|
onOk={() => form.submit()}
|
|
|
|
bodyStyle={{ height: 685 }}
|
|
|
|
bodyStyle={{ height: 685 }}
|
|
|
|
centered={false}
|
|
|
|
centered={false}
|
|
|
|
|
|
|
|
okButtonProps={{
|
|
|
|
|
|
|
|
loading: createTaskMutation.isLoading,
|
|
|
|
|
|
|
|
disabled: createTaskMutation.isLoading,
|
|
|
|
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<FormAnt
|
|
|
|
<FormAnt
|
|
|
|
form={form}
|
|
|
|
form={form}
|
|
|
|
|