feature/IO-3357-Reynolds-and-Reynolds-DMS-API-Integration - rr-Utils hardening

This commit is contained in:
Dave
2025-11-07 15:28:23 -05:00
parent 5a8a5bf7ab
commit fa250f10a2
2 changed files with 117 additions and 26 deletions

View File

@@ -28,11 +28,38 @@ function normalizeRrList(list) {
(custNo ? String(custNo) : "");
if (!custNo) return null;
const vinOwner = !!(row.vinOwner ?? row.isVehicleOwner);
return { custNo: String(custNo), name, vinOwner };
// Pass through address from backend if present; tolerate various shapes
const address =
row.address && typeof row.address === "object"
? {
line1: row.address.line1 ?? row.address.addr1 ?? row.address.Address1 ?? undefined,
line2: row.address.line2 ?? row.address.addr2 ?? row.address.Address2 ?? undefined,
city: row.address.city ?? undefined,
state: row.address.state ?? row.address.stateOrProvince ?? undefined,
postalCode: row.address.postalCode ?? row.address.zip ?? undefined,
country: row.address.country ?? row.address.countryCode ?? undefined
}
: undefined;
return { custNo: String(custNo), name, vinOwner, address };
})
.filter(Boolean);
}
// Small formatter used by the RR Address column render
function rrAddressToString(addr) {
if (!addr) return "";
const parts = [
addr.line1,
addr.line2,
[addr.city, addr.state].filter(Boolean).join(" "),
addr.postalCode,
addr.country
].filter(Boolean);
return parts.join(", ");
}
export function DmsCustomerSelector({ bodyshop, jobid }) {
const { t } = useTranslation();
const [customerList, setcustomerList] = useState([]);
@@ -278,6 +305,12 @@ export function DmsCustomerSelector({ bodyshop, jobid }) {
const rrColumns = [
{ title: t("jobs.fields.dms.id"), dataIndex: "custNo", key: "custNo" },
{
title: t("jobs.fields.dms.vinowner"),
dataIndex: "vinOwner",
key: "vinOwner",
render: (_t, r) => <Checkbox disabled checked={!!(r.vinOwner ?? r.isVehicleOwner)} />
},
{
title: t("jobs.fields.dms.name1"),
dataIndex: "name",
@@ -285,10 +318,9 @@ export function DmsCustomerSelector({ bodyshop, jobid }) {
sorter: (a, b) => alphaSort(a?.name, b?.name)
},
{
title: t("jobs.fields.dms.vinowner"),
dataIndex: "vinOwner",
key: "vinOwner",
render: (_t, r) => <Checkbox disabled checked={!!(r.vinOwner ?? r.isVehicleOwner)} />
title: t("jobs.fields.dms.address"),
key: "address",
render: (record) => rrAddressToString(record.address)
}
];