mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-03 06:53:24 +00:00
fix(work-orders): map only official primaryDispatchStatus (SH-183)
Drop undocumented board aliases so the Completed gate matches the backend DTO field.
This commit is contained in:
parent
5195749623
commit
f77428ab19
5 changed files with 21 additions and 18 deletions
|
|
@ -268,15 +268,7 @@ function readHasPendingUplift(
|
|||
}
|
||||
|
||||
function readPrimaryDispatchStatus(item: Record<string, unknown>): string {
|
||||
return readString(
|
||||
item,
|
||||
"primaryDispatchStatus",
|
||||
"PrimaryDispatchStatus",
|
||||
"dispatchStatus",
|
||||
"DispatchStatus",
|
||||
"vendorDispatchStatus",
|
||||
"VendorDispatchStatus",
|
||||
);
|
||||
return readString(item, "primaryDispatchStatus", "PrimaryDispatchStatus");
|
||||
}
|
||||
|
||||
export function mapWorkOrderTableRow(raw: unknown): WorkOrderTableRow {
|
||||
|
|
|
|||
|
|
@ -42,10 +42,8 @@ export interface WorkOrderBoardDetailInfoApi {
|
|||
dayGroup?: string | null;
|
||||
vendorId?: number | null;
|
||||
vendorName?: string | null;
|
||||
/** Primary dispatch status when the board contract supplies it (SH-183). */
|
||||
/** Exact board DTO field; inactive primary dispatch is not a live company (SH-183). */
|
||||
primaryDispatchStatus?: string | null;
|
||||
dispatchStatus?: string | null;
|
||||
vendorDispatchStatus?: string | null;
|
||||
techName?: string | null;
|
||||
techPhone?: string | null;
|
||||
apptDate?: string | null;
|
||||
|
|
|
|||
|
|
@ -184,10 +184,8 @@ export interface WorkOrderBoardRowApi {
|
|||
dayGroup?: string | null;
|
||||
vendorId?: number | null;
|
||||
vendorName?: string | null;
|
||||
/** Primary dispatch status when the board contract supplies it (SH-183). */
|
||||
/** Exact board DTO field; inactive primary dispatch is not a live company (SH-183). */
|
||||
primaryDispatchStatus?: string | null;
|
||||
dispatchStatus?: string | null;
|
||||
vendorDispatchStatus?: string | null;
|
||||
techName?: string | null;
|
||||
techPhone?: string | null;
|
||||
apptDate?: string | null;
|
||||
|
|
|
|||
|
|
@ -54,11 +54,20 @@ describe("mapWorkOrderTableRow isAddOn", () => {
|
|||
describe("mapWorkOrderTableRow primaryDispatchStatus", () => {
|
||||
it.each([
|
||||
["primaryDispatchStatus", "Refused"],
|
||||
["dispatchStatus", "Canceled"],
|
||||
["vendorDispatchStatus", "Cancelled"],
|
||||
] as const)("maps %s onto primaryDispatchStatus", (key, value) => {
|
||||
["PrimaryDispatchStatus", "Canceled"],
|
||||
] as const)("maps exact DTO field %s onto primaryDispatchStatus", (key, value) => {
|
||||
const row = mapWorkOrderTableRow({ id: 9, vendorId: 45, [key]: value });
|
||||
expect(row.vendorId).toBe("45");
|
||||
expect(row.primaryDispatchStatus).toBe(value);
|
||||
});
|
||||
|
||||
it("ignores undocumented dispatchStatus aliases", () => {
|
||||
const row = mapWorkOrderTableRow({
|
||||
id: 9,
|
||||
vendorId: 45,
|
||||
dispatchStatus: "Refused",
|
||||
vendorDispatchStatus: "Cancelled",
|
||||
});
|
||||
expect(row.primaryDispatchStatus).toBe("");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -428,6 +428,12 @@ describe("tableRowToClosabilityInput", () => {
|
|||
expect(getClosabilityGaps(input)).toContain("Company");
|
||||
},
|
||||
);
|
||||
|
||||
it("raises Company when the board omits vendor assignment (inactive primary, SH-183)", () => {
|
||||
const input = tableRowToClosabilityInput({ ...closableRow, vendorId: "", company: "" });
|
||||
expect(input.vendorId).toBe("");
|
||||
expect(getClosabilityGaps(input)).toContain("Company");
|
||||
});
|
||||
});
|
||||
|
||||
describe("readDetailWoType", () => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue