- Progress commit

Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
Dave Richer
2024-03-28 12:30:14 -04:00
parent ae9e9f4b72
commit dc22b96bed
8 changed files with 250 additions and 66 deletions

View File

@@ -32,7 +32,7 @@ export function TaskUpsertModalContainer({
const [updateTask] = useMutation(MUTATION_UPDATE_TASK);
const {open, context, actions} = taskUpsert;
const {jobId, existingTask} = context;
const {jobid, existingTask, joblineid, billid, partsorderid} = context;
const {refetch} = actions;
const [form] = Form.useForm();
const [selectedJobId, setSelectedJobId] = useState(null);
@@ -52,10 +52,10 @@ export function TaskUpsertModalContainer({
* Set the selected job id when the modal is opened and jobId is passed as a prop or when an existing task is passed as a prop
*/
useEffect(() => {
if (jobId || existingTask?.id) {
setSelectedJobId(jobId || existingTask.jobid);
if (jobid || existingTask?.id) {
setSelectedJobId(jobid || existingTask.jobid);
}
}, [jobId, existingTask]);
}, [jobid, existingTask]);
/**
* Set the form values when the modal is opened and an existing task is passed as a prop
@@ -65,9 +65,11 @@ export function TaskUpsertModalContainer({
form.setFieldsValue(existingTask);
} else if (!existingTask && open) {
form.resetFields();
if (joblineid) form.setFieldsValue({joblineid});
if (billid) form.setFieldsValue({billid});
if (partsorderid) form.setFieldsValue({partsorderid});
}
}, [existingTask, form, open]);
}, [existingTask, form, open, joblineid, billid, partsorderid]);
/**
* Set the job id state when the selected job id changes
@@ -125,10 +127,10 @@ export function TaskUpsertModalContainer({
fields: {
tasks(existingTasks) {
return [{
...values,
...values,
created_by: currentUser.email,
bodyshopid: bodyshop.id
}, ...existingTasks]
}, ...existingTasks]
},
},
});