@@ -30,7 +30,6 @@ export function TaskUpsertModalContainer({
|
||||
const {t} = useTranslation();
|
||||
const [insertTask] = useMutation(MUTATION_INSERT_NEW_TASK);
|
||||
const [updateTask] = useMutation(MUTATION_UPDATE_TASK);
|
||||
|
||||
const {open, context, actions} = taskUpsert;
|
||||
const {jobid, existingTask, joblineid, billid, partsorderid} = context;
|
||||
const {refetch} = actions;
|
||||
@@ -55,6 +54,9 @@ export function TaskUpsertModalContainer({
|
||||
if (jobid || existingTask?.id) {
|
||||
setSelectedJobId(jobid || existingTask.jobid);
|
||||
}
|
||||
return () => {
|
||||
setSelectedJobId(null);
|
||||
};
|
||||
}, [jobid, existingTask]);
|
||||
|
||||
/**
|
||||
@@ -105,7 +107,9 @@ export function TaskUpsertModalContainer({
|
||||
task: replaceUndefinedWithNull(values)
|
||||
},
|
||||
});
|
||||
|
||||
window.dispatchEvent( new CustomEvent('taskUpdated', {
|
||||
detail: { message: 'A task has been created or edited.' },
|
||||
}));
|
||||
notification["success"]({
|
||||
message: t("tasks.successes.updated"),
|
||||
});
|
||||
@@ -116,30 +120,36 @@ export function TaskUpsertModalContainer({
|
||||
variables: {
|
||||
taskInput: [
|
||||
{
|
||||
...replaceUndefinedWithNull(values),
|
||||
...values,
|
||||
created_by: currentUser.email,
|
||||
bodyshopid: bodyshop.id
|
||||
},
|
||||
],
|
||||
},
|
||||
update(cache) {
|
||||
cache.modify({
|
||||
fields: {
|
||||
tasks(existingTasks) {
|
||||
return [{
|
||||
...values,
|
||||
created_by: currentUser.email,
|
||||
bodyshopid: bodyshop.id
|
||||
}, ...existingTasks]
|
||||
},
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
// TODO: Consult Patrick, because this fails on relationship data, and an event emitter is just much easier to use
|
||||
// update(cache) {
|
||||
// cache.modify({
|
||||
// fields: {
|
||||
// tasks(existingTasks) {
|
||||
// return [{
|
||||
// ...values,
|
||||
// jobid: selectedJobId || values.jobid,
|
||||
// created_by: currentUser.email,
|
||||
// bodyshopid: bodyshop.id
|
||||
// }, ...existingTasks]
|
||||
// },
|
||||
// },
|
||||
// });
|
||||
// },
|
||||
|
||||
});
|
||||
if (refetch) await refetch();
|
||||
form.resetFields();
|
||||
toggleModalVisible();
|
||||
window.dispatchEvent( new CustomEvent('taskUpdated', {
|
||||
detail: { message: 'A task has been created or edited.' },
|
||||
}));
|
||||
notification["success"]({
|
||||
message: t("tasks.successes.created"),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user