feature/IO-3357-Reynolds-and-Reynolds-DMS-API-Integration - Checkpoint
This commit is contained in:
@@ -43,7 +43,7 @@ const DMS_SOCKET_EVENTS = {
|
||||
[DMS_MAP.reynolds]: {
|
||||
log: "rr-log-event",
|
||||
partialResult: "rr-export-job:result",
|
||||
cashierNeeded: "rr-cashiering-required",
|
||||
validationNeeded: "rr-validation-required",
|
||||
exportSuccess: "export-success",
|
||||
exportFailed: "export-failed"
|
||||
},
|
||||
@@ -104,7 +104,7 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
||||
const [rrOpenRoLimit, setRrOpenRoLimit] = useState(false);
|
||||
const clearRrOpenRoLimit = () => setRrOpenRoLimit(false);
|
||||
|
||||
const [rrCashierPending, setRrCashierPending] = useState(false);
|
||||
const [rrValidationPending, setrrValidationPending] = useState(false);
|
||||
|
||||
const { loading, error, data } = useQuery(QUERY_JOB_EXPORT_DMS, {
|
||||
variables: { id: jobId },
|
||||
@@ -259,8 +259,8 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
||||
const jobIdResolved = payload?.jobId ?? payload;
|
||||
notification.success({ message: t("jobs.successes.exported") });
|
||||
|
||||
// Clear RR cashier flag if any
|
||||
setRrCashierPending(false);
|
||||
// Clear RR Validation flag if any
|
||||
setrrValidationPending(false);
|
||||
|
||||
insertAuditTrail({
|
||||
jobid: jobIdResolved,
|
||||
@@ -276,40 +276,41 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
||||
// RR-only extras
|
||||
|
||||
const onPartialResult = () => {
|
||||
setRrCashierPending(true);
|
||||
setrrValidationPending(true);
|
||||
setLogs((prev) => [
|
||||
...prev,
|
||||
{
|
||||
timestamp: new Date(),
|
||||
level: "INFO",
|
||||
message:
|
||||
"Repair Order created in Reynolds. Complete cashiering in Reynolds, then click Finished/Close to finalize."
|
||||
"Repair Order created in Reynolds. Complete validation in Reynolds, then click Finished/Close to finalize."
|
||||
}
|
||||
]);
|
||||
notification.info({
|
||||
message: "Reynolds RO created",
|
||||
description:
|
||||
"Complete cashiering in Reynolds, then click Finished/Close to finalize and mark this export complete.",
|
||||
"Complete validation in Reynolds, then click Finished/Close to finalize and mark this export complete.",
|
||||
duration: 8
|
||||
});
|
||||
};
|
||||
|
||||
const onCashierRequired = (payload) => {
|
||||
setRrCashierPending(true);
|
||||
const onValidationRequired = (payload) => {
|
||||
setrrValidationPending(true);
|
||||
setLogs((prev) => [
|
||||
...prev,
|
||||
{
|
||||
timestamp: new Date(),
|
||||
level: "INFO",
|
||||
message:
|
||||
"Repair Order created in Reynolds. Complete cashiering in Reynolds, then click Finished/Close to finalize.",
|
||||
"Repair Order created in Reynolds. Complete validation in Reynolds, then click Finished/Close to finalize.",
|
||||
meta: { payload }
|
||||
}
|
||||
]);
|
||||
};
|
||||
|
||||
if (mode === DMS_MAP.reynolds && channels.partialResult) activeSocket.on(channels.partialResult, onPartialResult);
|
||||
if (mode === DMS_MAP.reynolds && channels.cashierNeeded) activeSocket.on(channels.cashierNeeded, onCashierRequired);
|
||||
if (mode === DMS_MAP.reynolds && channels.validationNeeded)
|
||||
activeSocket.on(channels.validationrNeeded, onValidationRequired);
|
||||
|
||||
return () => {
|
||||
activeSocket.off("connect", onConnect);
|
||||
@@ -323,8 +324,8 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
||||
|
||||
if (mode === DMS_MAP.reynolds && channels.partialResult)
|
||||
activeSocket.off(channels.partialResult, onPartialResult);
|
||||
if (mode === DMS_MAP.reynolds && channels.cashierNeeded)
|
||||
activeSocket.off(channels.cashierNeeded, onCashierRequired);
|
||||
if (mode === DMS_MAP.reynolds && channels.validationNeeded)
|
||||
activeSocket.off(channels.validationNeeded, onValidationRequired);
|
||||
|
||||
// Only tear down legacy socket listeners; don't disconnect WSS from here
|
||||
if (!isWssMode(mode)) {
|
||||
@@ -335,7 +336,7 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
||||
}, [mode, activeSocket, channels, logLevel, notification, t, insertAuditTrail, history]);
|
||||
|
||||
// RR finalize callback (unchanged public behavior)
|
||||
const handleRrCashierFinished = () => {
|
||||
const handleRrValidationFinished = () => {
|
||||
if (!jobId) return;
|
||||
if (!isWssMode(mode)) return; // RR is WSS-only
|
||||
activeSocket.emit("rr-finalize-repair-order", { jobId }, (ack) => {
|
||||
@@ -385,8 +386,8 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
||||
rrOptions={{
|
||||
openRoLimit: rrOpenRoLimit,
|
||||
onOpenRoFinished: clearRrOpenRoLimit,
|
||||
cashierPending: rrCashierPending,
|
||||
onCashierFinished: handleRrCashierFinished
|
||||
validationPending: rrValidationPending,
|
||||
onValidationFinished: handleRrValidationFinished
|
||||
}}
|
||||
/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user