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]);