mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-04 18:22:05 +00:00
* fix(work-orders): allow blank WO number in wizard create path
[recover] remove malicious eslint payload (was d0d08508)
* fix(work-orders): emit severity before type in board scalar PATCH ops
Co-authored-by: Cursor <cursoragent@cursor.com>
* chore(work-orders): drop vendor collateral from SH-192 lane
* fix(work-orders): add severity to unscheduled highlight fixture after dev merge
* refactor(work-orders): extract inline type/severity cell under function line cap
* fix(work-orders): add severity to comp-doc and media fixtures after dev merge
PR #45 introduced completion-doc, media and table-mutation fixtures that predate the required severity field, so the integrated head failed tsc. Fill severity on those row builders (null for PM, SEV 1 for the Emergency fixture) and type the mutation BASE_ROW instead of asserting it.
* test(work-orders): align merge fixes with severity field and WO# placeholder
---------
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Arthur Bassi <bassi-arthurr@users.noreply.github.com>
Co-authored-by: Alexandre Brandizzi <alex_brandizzi@hotmail.com>
52 lines
2.3 KiB
TypeScript
52 lines
2.3 KiB
TypeScript
import type { WorkOrderBoardEditableField } from "@/domain/work-orders/types/work-order-board";
|
|
import type { WorkOrderTablePatch } from "@/domain/work-orders/types/work-order-table-row";
|
|
import { mapDocStatusToApi } from "@/domain/work-orders/mappers/doc-status-mapper";
|
|
|
|
export type BoardFieldOp = {
|
|
field: WorkOrderBoardEditableField;
|
|
value: string;
|
|
};
|
|
|
|
export { mapDocStatusToApi };
|
|
|
|
type ScalarBoardOpRule = {
|
|
key: keyof WorkOrderTablePatch;
|
|
field: WorkOrderBoardEditableField;
|
|
toValue: (value: unknown) => string;
|
|
};
|
|
|
|
/** One row per scalar patch field, in emission order. */
|
|
const SCALAR_BOARD_OP_RULES: ScalarBoardOpRule[] = [
|
|
{ key: "woNumber", field: "woNumber", toValue: (value) => value as string },
|
|
// Severity before type so Emergency/Reactive never land without required severity.
|
|
{
|
|
key: "severity",
|
|
field: "severity",
|
|
toValue: (value) => (value == null ? "" : String(value)),
|
|
},
|
|
{ key: "type", field: "workOrderType", toValue: (value) => value as string },
|
|
{ key: "site", field: "siteCode", toValue: (value) => value as string },
|
|
{ key: "status", field: "lifecycleStatus", toValue: (value) => value as string },
|
|
{ key: "dispatcherId", field: "assignTo", toValue: (value) => value as string },
|
|
{ key: "dueDate", field: "dueDate", toValue: (value) => value as string },
|
|
{ key: "vendorId", field: "vendorId", toValue: (value) => String(value) },
|
|
{ key: "apptTime", field: "apptTime", toValue: (value) => value as string },
|
|
{ key: "docStatus", field: "docStatus", toValue: (value) => mapDocStatusToApi(value as string) },
|
|
{ key: "completedDate", field: "completedDate", toValue: (value) => value as string },
|
|
{ key: "pm", field: "pm", toValue: (value) => value as string },
|
|
{ key: "extraServices", field: "extraServices", toValue: (value) => JSON.stringify(value) },
|
|
{ key: "serviceNotes", field: "serviceNotes", toValue: (value) => value as string },
|
|
{ key: "flagColor", field: "flagColor", toValue: (value) => (value as string | null) ?? "" },
|
|
];
|
|
|
|
export function expandScalarBoardOps(patch: WorkOrderTablePatch): BoardFieldOp[] {
|
|
const ops: BoardFieldOp[] = [];
|
|
|
|
for (const rule of SCALAR_BOARD_OP_RULES) {
|
|
const value = patch[rule.key];
|
|
if (value === undefined) continue;
|
|
ops.push({ field: rule.field, value: rule.toValue(value) });
|
|
}
|
|
|
|
return ops;
|
|
}
|