rrScratch3 - Progress Commit
This commit is contained in:
@@ -66,16 +66,6 @@ const DMS_SOCKET_EVENTS = {
|
||||
};
|
||||
|
||||
export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, insertAuditTrail }) {
|
||||
const { t } = useTranslation();
|
||||
const [resetAfterReconnect, setResetAfterReconnect] = useState(false);
|
||||
const [allocationsSummary, setAllocationsSummary] = useState(null);
|
||||
|
||||
const history = useNavigate();
|
||||
const search = queryString.parse(useLocation().search);
|
||||
const { jobId } = search;
|
||||
|
||||
const notification = useNotification();
|
||||
|
||||
const {
|
||||
treatments: { Fortellis }
|
||||
} = useSplitTreatments({
|
||||
@@ -84,10 +74,46 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
||||
splitKey: bodyshop.imexshopid
|
||||
});
|
||||
|
||||
const { t } = useTranslation();
|
||||
const [resetAfterReconnect, setResetAfterReconnect] = useState(false);
|
||||
const [allocationsSummary, setAllocationsSummary] = useState(null);
|
||||
|
||||
// Compute a single normalized mode and pick the proper socket
|
||||
const mode = getDmsMode(bodyshop, Fortellis.treatment); // "rr" | "fortellis" | "cdk" | "pbs" | "none"
|
||||
|
||||
// RR-only: derive default OpCode parts from bodyshop RR configuration
|
||||
const isRrMode = mode === DMS_MAP.reynolds;
|
||||
|
||||
const deriveDefaultRrOpCodeParts = () => {
|
||||
if (!isRrMode) return null;
|
||||
|
||||
const cfg = bodyshop?.rr_configuration || {};
|
||||
|
||||
// Adjust these paths to match your real schema.
|
||||
const defaults =
|
||||
cfg.opCodeDefault ||
|
||||
cfg.op_code_default ||
|
||||
cfg.op_codes?.default ||
|
||||
cfg.defaults?.opCode ||
|
||||
cfg.defaults ||
|
||||
cfg.default ||
|
||||
{};
|
||||
|
||||
const prefix = defaults.prefix ?? defaults.opCodePrefix ?? "";
|
||||
const base = defaults.base ?? defaults.opCodeBase ?? "";
|
||||
const suffix = defaults.suffix ?? defaults.opCodeSuffix ?? "";
|
||||
|
||||
return { prefix, base, suffix };
|
||||
};
|
||||
|
||||
const [rrOpCodeParts, setRrOpCodeParts] = useState(() => deriveDefaultRrOpCodeParts());
|
||||
|
||||
const history = useNavigate();
|
||||
const search = queryString.parse(useLocation().search);
|
||||
const { jobId } = search;
|
||||
|
||||
const notification = useNotification();
|
||||
|
||||
const { socket: wsssocket } = useSocket();
|
||||
const activeSocket = useMemo(() => (isWssMode(mode) ? wsssocket : legacySocket), [mode, wsssocket]);
|
||||
|
||||
@@ -96,6 +122,12 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
||||
// One place to set log level
|
||||
const [logLevel, setLogLevel] = useState(mode === DMS_MAP.pbs ? "INFO" : "DEBUG");
|
||||
|
||||
const rrOpCodeCombined = useMemo(() => {
|
||||
if (!rrOpCodeParts || !rrOpCodeParts.base) return "";
|
||||
const { prefix, base, suffix } = rrOpCodeParts;
|
||||
return `${prefix || ""}${base}${suffix || ""}`;
|
||||
}, [rrOpCodeParts]);
|
||||
|
||||
const setActiveLogLevel = (level) => {
|
||||
if (!activeSocket) return;
|
||||
activeSocket.emit("set-log-level", level);
|
||||
@@ -155,6 +187,9 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
||||
setrrValidationPending(false);
|
||||
setAllocationsSummary(null);
|
||||
|
||||
// RR OpCode parts: reset to config defaults when job/mode changes
|
||||
setRrOpCodeParts(deriveDefaultRrOpCodeParts());
|
||||
|
||||
if (!activeSocket) return;
|
||||
|
||||
const emitReset = () => {
|
||||
@@ -431,6 +466,7 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
||||
}
|
||||
socket={activeSocket}
|
||||
jobId={jobId}
|
||||
opCode={rrOpCodeCombined}
|
||||
/>
|
||||
)}
|
||||
</Col>
|
||||
@@ -443,6 +479,8 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
||||
logsRef={logsRef}
|
||||
mode={mode}
|
||||
allocationsSummary={allocationsSummary}
|
||||
rrOpCodeParts={rrOpCodeParts}
|
||||
onChangeRrOpCodeParts={setRrOpCodeParts}
|
||||
/>
|
||||
</Col>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user