From 5c54cf6c44d466398e77a5b2da171b8c709f1f20 Mon Sep 17 00:00:00 2001 From: Dave Richer Date: Mon, 16 Sep 2024 11:48:17 -0400 Subject: [PATCH] feature/IO-2924-Refactor-Production-Board-For-Sockets - Checkpoint Signed-off-by: Dave Richer --- .../dms-allocations-summary-ap.component.jsx | 13 +---------- .../dms-allocations-summary.component.jsx | 2 +- .../dms-payables/dms-payables.container.jsx | 2 +- client/src/pages/dms/dms.container.jsx | 4 ++-- .../pages/manage/manage.page.component.jsx | 12 ++++++++++ server.js | 4 +++- server/web-sockets/web-socket.js | 22 +++++++++---------- 7 files changed, 30 insertions(+), 29 deletions(-) diff --git a/client/src/components/dms-allocations-summary-ap/dms-allocations-summary-ap.component.jsx b/client/src/components/dms-allocations-summary-ap/dms-allocations-summary-ap.component.jsx index abbde7277..0125191dd 100644 --- a/client/src/components/dms-allocations-summary-ap/dms-allocations-summary-ap.component.jsx +++ b/client/src/components/dms-allocations-summary-ap/dms-allocations-summary-ap.component.jsx @@ -20,7 +20,7 @@ export function DmsAllocationsSummaryAp({ bodyshop, billids, title }) { const { socket } = useContext(SocketContext); useEffect(() => { - if (!socket) return; + if (!socket || !socket.connected) return; const handleSuccess = async (billid) => { setAllocationsSummary((allocationsSummary) => @@ -45,21 +45,10 @@ export function DmsAllocationsSummaryAp({ bodyshop, billids, title }) { } }; - const handleFailure = ({ billid, error }) => { - setAllocationsSummary((allocationsSummary) => - allocationsSummary.map((a) => { - if (a.billid !== billid) return a; - return { ...a, status: error }; - }) - ); - }; - socket.on("ap-export-success", handleSuccess); - socket.on("ap-export-failure", handleFailure); return () => { socket.off("ap-export-success", handleSuccess); - socket.off("ap-export-failure", handleFailure); }; }, [socket]); diff --git a/client/src/components/dms-allocations-summary/dms-allocations-summary.component.jsx b/client/src/components/dms-allocations-summary/dms-allocations-summary.component.jsx index 3551cc6e3..cbc2680dd 100644 --- a/client/src/components/dms-allocations-summary/dms-allocations-summary.component.jsx +++ b/client/src/components/dms-allocations-summary/dms-allocations-summary.component.jsx @@ -24,7 +24,7 @@ export function DmsAllocationsSummary({ socket, bodyshop, jobId, title }) { const [allocationsSummary, setAllocationsSummary] = useState([]); useEffect(() => { - if (socket.connected) { + if (socket && socket.connected) { socket.emit("cdk-calculate-allocations", jobId, (ack) => { setAllocationsSummary(ack); socket.allocationsSummary = ack; diff --git a/client/src/pages/dms-payables/dms-payables.container.jsx b/client/src/pages/dms-payables/dms-payables.container.jsx index 15117c94d..c354687fb 100644 --- a/client/src/pages/dms-payables/dms-payables.container.jsx +++ b/client/src/pages/dms-payables/dms-payables.container.jsx @@ -60,7 +60,7 @@ export function DmsContainer({ setBreadcrumbs, setSelectedHeader }) { { timestamp: new Date(), level: "WARNING", - message: "Reconnected to CDK Export Service" + message: "Reconnected to DMS Export Service" } ]); }; diff --git a/client/src/pages/dms/dms.container.jsx b/client/src/pages/dms/dms.container.jsx index ab1d40f95..1328595cc 100644 --- a/client/src/pages/dms/dms.container.jsx +++ b/client/src/pages/dms/dms.container.jsx @@ -90,7 +90,7 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse { timestamp: new Date(), level: "WARNING", - message: "Reconnected to CDK Export Service" + message: "Reconnected to DMS Export Service" } ]); }; @@ -201,7 +201,7 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse WARNING ERROR - 4 +