feature/IO-3357-Reynolds-and-Reynolds-DMS-API-Integration -Checkpoint

This commit is contained in:
Dave
2025-11-10 12:20:30 -05:00
parent d45d557a81
commit 02eb212758
4 changed files with 182 additions and 24 deletions

View File

@@ -79,6 +79,42 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
});
const logsRef = useRef(null);
const handleExportFailed = (payload = {}) => {
const { title, friendlyMessage, error, severity, errorCode, vendorStatusCode } = payload;
// Prefer server-provided nice text; otherwise generic fallback
const msg =
friendlyMessage ||
error ||
t("dms.errors.exportfailedgeneric", "We couldn't complete the export. Please try again.");
// Title defaults by DMS
const vendorTitle = title || (dms === "rr" ? "Reynolds" : "DMS");
// Severity: warn for known soft-stops like 507, else error
const sev =
severity || (vendorStatusCode === 507 || (errorCode || "").includes("MAX_OPEN_ROS") ? "warning" : "error");
const notifyKind = sev === "warning" && typeof notification.warning === "function" ? "warning" : "error";
notification[notifyKind]({
message: vendorTitle,
description: msg,
duration: 10
});
// Mirror to the on-screen log card
setLogs((prev) => [
...prev,
{
timestamp: new Date(),
level: (sev || "error").toUpperCase(),
message: `${vendorTitle}: ${msg}`,
meta: { errorCode, vendorStatusCode, raw: payload }
}
]);
};
useEffect(() => {
document.title = t("titles.dms", {
app: InstanceRenderManager({
@@ -134,17 +170,21 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
// RR channels (over wss)
wsssocket.on("rr-log-event", handleLogEvent);
wsssocket.on("RR:LOG", handleLogEvent);
wsssocket.on("export-success", handleExportSuccess);
wsssocket.on("rr-export-job:result", handleRrExportResult);
wsssocket.on("export-success", handleExportSuccess);
wsssocket.on("export-failed", handleExportFailed);
return () => {
wsssocket.off("connect", handleConnect);
wsssocket.off("reconnect", handleReconnect);
wsssocket.off("connect_error", handleConnectError);
wsssocket.off("rr-log-event", handleLogEvent);
wsssocket.off("export-success", handleExportSuccess);
wsssocket.off("rr-export-job:result", handleRrExportResult);
wsssocket.off("export-success", handleExportSuccess);
wsssocket.off("export-failed", handleExportFailed);
};
}
@@ -166,13 +206,17 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
// Fortellis logs (wss)
wsssocket.on("fortellis-log-event", handleLogEvent);
wsssocket.on("export-success", handleExportSuccess);
wsssocket.on("export-failed", handleExportFailed);
return () => {
wsssocket.off("fortellis-log-event", handleLogEvent);
wsssocket.off("export-success", handleExportSuccess);
wsssocket.off("export-failed", handleExportFailed);
};
} else {
// CDK/PBS via legacy /ws socket
socket.on("export-failed", handleExportFailed);
socket.on("connect", () => socket.emit("set-log-level", logLevel));
socket.on("reconnect", () => {
setLogs((prev) => [