feature/IO-3499-React-19: Bug Fixes / Checkpoint
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Alert, Button, Card, Table, Typography } from "antd";
|
||||
import { SyncOutlined } from "@ant-design/icons";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { useCallback, useEffect, useState, useRef } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
@@ -31,6 +31,11 @@ export default connect(mapStateToProps, mapDispatchToProps)(DmsAllocationsSummar
|
||||
export function DmsAllocationsSummary({ mode, socket, bodyshop, jobId, title, onAllocationsChange }) {
|
||||
const { t } = useTranslation();
|
||||
const [allocationsSummary, setAllocationsSummary] = useState([]);
|
||||
const socketRef = useRef(socket);
|
||||
|
||||
useEffect(() => {
|
||||
socketRef.current = socket;
|
||||
}, [socket]);
|
||||
|
||||
// Resolve event name by mode (PBS reuses the CDK event per existing behavior)
|
||||
const allocationsEvent =
|
||||
@@ -48,14 +53,14 @@ export function DmsAllocationsSummary({ mode, socket, bodyshop, jobId, title, on
|
||||
const list = Array.isArray(ack) ? ack : [];
|
||||
setAllocationsSummary(list);
|
||||
// Preserve side-channel used by the post form for discrepancy checks
|
||||
socket.allocationsSummary = list;
|
||||
socketRef.current.allocationsSummary = list;
|
||||
if (onAllocationsChange) onAllocationsChange(list);
|
||||
});
|
||||
} catch {
|
||||
// Best-effort; leave table empty on error
|
||||
setAllocationsSummary([]);
|
||||
if (socket) {
|
||||
socket.allocationsSummary = [];
|
||||
if (socketRef.current) {
|
||||
socketRef.current.allocationsSummary = [];
|
||||
}
|
||||
if (onAllocationsChange) {
|
||||
onAllocationsChange([]);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Alert, Button, Card, Table, Tabs, Typography } from "antd";
|
||||
import { SyncOutlined } from "@ant-design/icons";
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { useCallback, useEffect, useMemo, useState, useRef } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
@@ -74,6 +74,11 @@ export function RrAllocationsSummary({ socket, bodyshop, jobId, title, onAllocat
|
||||
const [roggPreview, setRoggPreview] = useState(null);
|
||||
const [rolaborPreview, setRolaborPreview] = useState(null);
|
||||
const [error, setError] = useState(null);
|
||||
const socketRef = useRef(socket);
|
||||
|
||||
useEffect(() => {
|
||||
socketRef.current = socket;
|
||||
}, [socket]);
|
||||
|
||||
// Prefer the user-selected OpCode (from DmsContainer), fall back to config default
|
||||
const effectiveOpCode = useMemo(() => opCode || resolveRROpCodeFromBodyshop(bodyshop), [opCode, bodyshop]);
|
||||
@@ -87,9 +92,9 @@ export function RrAllocationsSummary({ socket, bodyshop, jobId, title, onAllocat
|
||||
setRoggPreview(null);
|
||||
setRolaborPreview(null);
|
||||
setError(ack.error || t("dms.labels.allocations_error"));
|
||||
if (socket) {
|
||||
socket.allocationsSummary = [];
|
||||
socket.rrAllocationsRaw = ack;
|
||||
if (socketRef.current) {
|
||||
socketRef.current.allocationsSummary = [];
|
||||
socketRef.current.rrAllocationsRaw = ack;
|
||||
}
|
||||
if (onAllocationsChange) {
|
||||
onAllocationsChange([]);
|
||||
@@ -103,9 +108,9 @@ export function RrAllocationsSummary({ socket, bodyshop, jobId, title, onAllocat
|
||||
setRolaborPreview(ack?.rolabor || null);
|
||||
setError(null);
|
||||
|
||||
if (socket) {
|
||||
socket.allocationsSummary = jobAllocRows;
|
||||
socket.rrAllocationsRaw = ack;
|
||||
if (socketRef.current) {
|
||||
socketRef.current.allocationsSummary = jobAllocRows;
|
||||
socketRef.current.rrAllocationsRaw = ack;
|
||||
}
|
||||
if (onAllocationsChange) {
|
||||
onAllocationsChange(jobAllocRows);
|
||||
@@ -115,8 +120,8 @@ export function RrAllocationsSummary({ socket, bodyshop, jobId, title, onAllocat
|
||||
setRoggPreview(null);
|
||||
setRolaborPreview(null);
|
||||
setError(t("dms.labels.allocations_error"));
|
||||
if (socket) {
|
||||
socket.allocationsSummary = [];
|
||||
if (socketRef.current) {
|
||||
socketRef.current.allocationsSummary = [];
|
||||
}
|
||||
if (onAllocationsChange) {
|
||||
onAllocationsChange([]);
|
||||
|
||||
Reference in New Issue
Block a user