feature/IO-3357-Reynolds-and-Reynolds-DMS-API-Integration - Refresh button inside VIN Enforced, add TOo Many OPen RO Handlers
This commit is contained in:
@@ -79,29 +79,41 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
||||
});
|
||||
const logsRef = useRef(null);
|
||||
|
||||
// NEW: RR “open RO limit” UX hold
|
||||
const [rrOpenRoLimit, setRrOpenRoLimit] = useState(false);
|
||||
const clearRrOpenRoLimit = () => setRrOpenRoLimit(false);
|
||||
|
||||
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");
|
||||
// Detect the specific RR “max open ROs” case
|
||||
const isRrOpenRoLimit =
|
||||
dms === "rr" &&
|
||||
(vendorStatusCode === 507 ||
|
||||
/MAX_OPEN_ROS/i.test(String(errorCode || "")) ||
|
||||
/maximum number of open repair orders/i.test(String(msg || "").toLowerCase()));
|
||||
|
||||
const notifyKind = sev === "warning" && typeof notification.warning === "function" ? "warning" : "error";
|
||||
// Soft/warn default for known cases
|
||||
const sev = severity || (isRrOpenRoLimit ? "warning" : "error");
|
||||
|
||||
notification[notifyKind]({
|
||||
message: vendorTitle,
|
||||
description: msg,
|
||||
duration: 10
|
||||
});
|
||||
// Show toast for *other* failures; for the open RO limit, switch to blocking banner UX instead.
|
||||
if (!isRrOpenRoLimit) {
|
||||
const notifyKind = sev === "warning" && typeof notification.warning === "function" ? "warning" : "error";
|
||||
notification[notifyKind]({
|
||||
message: vendorTitle,
|
||||
description: msg,
|
||||
duration: 10
|
||||
});
|
||||
} else {
|
||||
setRrOpenRoLimit(true);
|
||||
}
|
||||
|
||||
// Mirror to the on-screen log card
|
||||
setLogs((prev) => [
|
||||
@@ -110,7 +122,7 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
||||
timestamp: new Date(),
|
||||
level: (sev || "error").toUpperCase(),
|
||||
message: `${vendorTitle}: ${msg}`,
|
||||
meta: { errorCode, vendorStatusCode, raw: payload }
|
||||
meta: { errorCode, vendorStatusCode, raw: payload, blockedByOpenRoLimit: !!isRrOpenRoLimit }
|
||||
}
|
||||
]);
|
||||
};
|
||||
@@ -154,7 +166,8 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
||||
const handleLogEvent = (payload) => setLogs((prev) => [...prev, payload]);
|
||||
|
||||
const handleExportSuccess = (payload) => {
|
||||
const jobId = payload?.jobId ?? payload; // RR sends object; legacy sends raw id notification.success({ message: t("jobs.successes.exported") });
|
||||
const jobId = payload?.jobId ?? payload; // RR sends object; legacy sends raw id
|
||||
notification.success({ message: t("jobs.successes.exported") });
|
||||
insertAuditTrail({
|
||||
jobid: jobId,
|
||||
operation: AuditTrailMapping.jobexported(),
|
||||
@@ -283,11 +296,10 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
||||
/>
|
||||
</Col>
|
||||
<Col md={24} lg={14}>
|
||||
<DmsPostForm socket={activeSocket} jobId={jobId} job={data?.jobs_by_pk} logsRef={logsRef} />
|
||||
<DmsPostForm socket={activeSocket} job={data?.jobs_by_pk} logsRef={logsRef} />
|
||||
</Col>
|
||||
|
||||
<DmsCustomerSelector jobid={jobId} />
|
||||
|
||||
<DmsCustomerSelector jobid={jobId} rrOpenRoLimit={rrOpenRoLimit} onRrOpenRoFinished={clearRrOpenRoLimit} />
|
||||
<Col span={24}>
|
||||
<div ref={logsRef}>
|
||||
<Card
|
||||
@@ -316,9 +328,7 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
||||
<Button
|
||||
onClick={() => {
|
||||
setLogs([]);
|
||||
// Reconnect appropriate socket
|
||||
if (dms === "rr" || Fortellis.treatment === "on") {
|
||||
// wsssocket is managed by provider; emit a ping
|
||||
wsssocket.emit("set-log-level", logLevel);
|
||||
} else {
|
||||
socket.disconnect();
|
||||
|
||||
Reference in New Issue
Block a user