feature/IO-3357-Reynolds-and-Reynolds-DMS-API-Integration / RRScratch2 / Math Adjustments / DMS State cleaning on Page load
This commit is contained in:
@@ -142,6 +142,41 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
||||
isConnected ? "Connected" : "Disconnected"
|
||||
}`;
|
||||
|
||||
const resetKey = useMemo(() => `${mode || "none"}-${jobId || "none"}`, [mode, jobId]);
|
||||
|
||||
// 🔄 Hard reset of local + server-side DMS context when the page/job loads
|
||||
useEffect(() => {
|
||||
// Clear any local ephemeral state that might be stale
|
||||
setLogs([]);
|
||||
setRrOpenRoLimit(false);
|
||||
setrrValidationPending(false);
|
||||
|
||||
if (!activeSocket) return;
|
||||
|
||||
const emitReset = () => {
|
||||
// Generic reset; server can branch on `mode` if needed
|
||||
activeSocket.emit("dms-reset-context", { jobId, mode });
|
||||
};
|
||||
|
||||
if (activeSocket.connected) {
|
||||
// WSS usually lands here
|
||||
emitReset();
|
||||
return;
|
||||
}
|
||||
|
||||
// Legacy WS: wait for the connect before emitting reset
|
||||
const handleConnectOnce = () => {
|
||||
emitReset();
|
||||
activeSocket.off("connect", handleConnectOnce);
|
||||
};
|
||||
|
||||
activeSocket.on("connect", handleConnectOnce);
|
||||
|
||||
return () => {
|
||||
activeSocket.off("connect", handleConnectOnce);
|
||||
};
|
||||
}, [jobId, mode, activeSocket]);
|
||||
|
||||
const handleExportFailed = (payload = {}) => {
|
||||
const { title, friendlyMessage, error: errText, severity, errorCode, vendorStatusCode } = payload;
|
||||
|
||||
@@ -355,6 +390,7 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
||||
<Col md={24} lg={10}>
|
||||
{!isRrMode ? (
|
||||
<DmsAllocationsSummary
|
||||
key={resetKey}
|
||||
title={
|
||||
<span>
|
||||
<Link
|
||||
@@ -371,6 +407,7 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
||||
/>
|
||||
) : (
|
||||
<RrAllocationsSummary
|
||||
key={resetKey}
|
||||
title={
|
||||
<span>
|
||||
<Link to={`/manage/jobs/${data && data.jobs_by_pk.id}`}>
|
||||
@@ -388,7 +425,7 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
||||
</Col>
|
||||
|
||||
<Col md={24} lg={14}>
|
||||
<DmsPostForm socket={activeSocket} job={data?.jobs_by_pk} logsRef={logsRef} mode={mode} />
|
||||
<DmsPostForm key={resetKey} socket={activeSocket} job={data?.jobs_by_pk} logsRef={logsRef} mode={mode} />
|
||||
</Col>
|
||||
|
||||
<DmsCustomerSelector
|
||||
|
||||
Reference in New Issue
Block a user