feature/IO-3357-Reynolds-and-Reynolds-DMS-API-Integration - Fixes to Caching of allocations summary

This commit is contained in:
Dave
2025-11-28 11:29:48 -05:00
parent d885bac7d0
commit c1e3c08652
6 changed files with 93 additions and 31 deletions

View File

@@ -24,10 +24,11 @@ export default connect(mapStateToProps, mapDispatchToProps)(DmsAllocationsSummar
* @param bodyshop
* @param jobId
* @param title
* @param onAllocationsChange
* @returns {JSX.Element}
* @constructor
*/
export function DmsAllocationsSummary({ mode, socket, bodyshop, jobId, title }) {
export function DmsAllocationsSummary({ mode, socket, bodyshop, jobId, title, onAllocationsChange }) {
const { t } = useTranslation();
const [allocationsSummary, setAllocationsSummary] = useState([]);
@@ -48,11 +49,17 @@ export function DmsAllocationsSummary({ mode, socket, bodyshop, jobId, title })
setAllocationsSummary(list);
// Preserve side-channel used by the post form for discrepancy checks
socket.allocationsSummary = list;
if (onAllocationsChange) onAllocationsChange(list);
});
} catch {
// Best-effort; leave table empty on error
setAllocationsSummary([]);
socket && (socket.allocationsSummary = []);
if (socket) {
socket.allocationsSummary = [];
}
if (onAllocationsChange) {
onAllocationsChange([]);
}
}
}, [socket, jobId, mode, allocationsEvent]);

View File

@@ -51,7 +51,7 @@ function normalizeJobAllocations(ack) {
* is now done on the backend via buildRogogFromAllocations/buildRolaborFromRogog.
* This component just renders the preview from `ack.rogg` / `ack.rolabor`.
*/
export function RrAllocationsSummary({ socket, bodyshop, jobId, title }) {
export function RrAllocationsSummary({ socket, bodyshop, jobId, title, onAllocationsChange }) {
const { t } = useTranslation();
const [roggPreview, setRoggPreview] = useState(null);
const [rolaborPreview, setRolaborPreview] = useState(null);
@@ -70,6 +70,9 @@ export function RrAllocationsSummary({ socket, bodyshop, jobId, title }) {
socket.allocationsSummary = [];
socket.rrAllocationsRaw = ack;
}
if (onAllocationsChange) {
onAllocationsChange([]);
}
return;
}
@@ -83,6 +86,9 @@ export function RrAllocationsSummary({ socket, bodyshop, jobId, title }) {
socket.allocationsSummary = jobAllocRows;
socket.rrAllocationsRaw = ack;
}
if (onAllocationsChange) {
onAllocationsChange(jobAllocRows);
}
});
} catch {
setRoggPreview(null);
@@ -91,8 +97,11 @@ export function RrAllocationsSummary({ socket, bodyshop, jobId, title }) {
if (socket) {
socket.allocationsSummary = [];
}
if (onAllocationsChange) {
onAllocationsChange([]);
}
}
}, [socket, jobId, t]);
}, [socket, jobId, t, onAllocationsChange]);
useEffect(() => {
fetchAllocations();