From 1343b68cc601b6566223076ade9e484869c1616e Mon Sep 17 00:00:00 2001 From: Dave Richer Date: Mon, 1 Apr 2024 16:34:31 -0400 Subject: [PATCH] - Progress Commit Signed-off-by: Dave Richer --- .../task-list/task-list.component.jsx | 2 ++ .../task-list/task-list.container.jsx | 31 +++++++++---------- .../jobs-detail.page.component.jsx | 12 +++++++ 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/client/src/components/task-list/task-list.component.jsx b/client/src/components/task-list/task-list.component.jsx index 0daf79ebb..a331612b7 100644 --- a/client/src/components/task-list/task-list.component.jsx +++ b/client/src/components/task-list/task-list.component.jsx @@ -118,6 +118,8 @@ function TaskListComponent({ dataIndex: "assigned_to", key: "assigned_to", width: '10%', + sorter: true, + sortOrder: sortcolumn === "assigned_to" && sortorder, } ); } diff --git a/client/src/components/task-list/task-list.container.jsx b/client/src/components/task-list/task-list.container.jsx index 5db08ab73..d2b24ffcb 100644 --- a/client/src/components/task-list/task-list.container.jsx +++ b/client/src/components/task-list/task-list.container.jsx @@ -46,18 +46,9 @@ export default function TaskListContainer({bodyshop, titleTranslation ,query, r * Refetch tasks when a task is updated */ useEffect(() => { - const handleTaskUpdated = () => { - refetch().catch((e) => { - console.error(`Something went wrong fetching tasks: ${e.message || ''}`); - }); + const handleTaskUpdated = async (event) => { + await refetch().catch(e => `Something went wrong fetching tasks: ${e.message || ''}`); }; - }, [refetch]); - - useEffect(() => { - const handleTaskUpdated = (event) => { - refetch(); - }; - window.addEventListener('taskUpdated', handleTaskUpdated); // Clean up the event listener when the component is unmounted. @@ -87,9 +78,12 @@ export default function TaskListContainer({bodyshop, titleTranslation ,query, r completed_at: completed_at } }); - refetch().catch((e) => { - console.error(`Something went wrong fetching tasks: ${e.message || ''}`); - }); + // refetch().catch((e) => { + // console.error(`Something went wrong fetching tasks: ${e.message || ''}`); + // }); + window.dispatchEvent( new CustomEvent('taskUpdated', { + detail: { message: 'A task has been completed.' }, + })); notification["success"]({ message: t("tasks.successes.completed"), }); @@ -121,9 +115,12 @@ export default function TaskListContainer({bodyshop, titleTranslation ,query, r deleted_at: deleted_at } }); - refetch().catch((e) => { - console.error(`Something went wrong fetching tasks: ${e.message || ''}`); - }); + window.dispatchEvent( new CustomEvent('taskUpdated', { + detail: { message: 'A task has been deleted.' }, + })); + // refetch().catch((e) => { + // console.error(`Something went wrong fetching tasks: ${e.message || ''}`); + // }); notification["success"]({ message: t("tasks.successes.deleted"), }); diff --git a/client/src/pages/jobs-detail/jobs-detail.page.component.jsx b/client/src/pages/jobs-detail/jobs-detail.page.component.jsx index 423287a8a..0dd37b81c 100644 --- a/client/src/pages/jobs-detail/jobs-detail.page.component.jsx +++ b/client/src/pages/jobs-detail/jobs-detail.page.component.jsx @@ -109,6 +109,18 @@ export function JobsDetailPage({ form.resetFields(); }, [form, job]); + useEffect(() => { + const handleTaskUpdated = async (event) => { + await refetch().catch(e => `Something went wrong fetching tasks: ${e.message || ''}`); + }; + window.addEventListener('taskUpdated', handleTaskUpdated); + + // Clean up the event listener when the component is unmounted. + return () => { + window.removeEventListener('taskUpdated', handleTaskUpdated); + }; + }, [refetch]); + //useKeyboardSaveShortcut(form.submit); const handleFinish = async (values) => {