feature/IO-3357-Reynolds-and-Reynolds-DMS-API-Integration - Fixes to Caching of allocations summary
This commit is contained in:
@@ -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]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user