mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-04 09:02:05 +00:00
Split oversized API/mapper/UI modules and extract focused helpers so the exact head satisfies godfile and complexity ratchets without relaxing thresholds.
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import type { BoardFieldOp } from "@/domain/work-orders/mappers/expand-scalar-board-ops";
|
|
import type { WorkOrderTablePatch } from "@/domain/work-orders/types/work-order-table-row";
|
|
|
|
function hasScheduleRelatedPatch(patch: WorkOrderTablePatch): boolean {
|
|
return (
|
|
patch.scheduledOn !== undefined ||
|
|
patch.targetWeek !== undefined ||
|
|
patch.scheduleWeekOnly !== undefined
|
|
);
|
|
}
|
|
|
|
/** Schedule/week-only ops in the stable order the board API expects. */
|
|
export function expandScheduleBoardOps(patch: WorkOrderTablePatch): BoardFieldOp[] {
|
|
if (!hasScheduleRelatedPatch(patch)) {
|
|
return [];
|
|
}
|
|
|
|
const ops: BoardFieldOp[] = [];
|
|
|
|
if (patch.scheduleWeekOnly === true) {
|
|
ops.push({ field: "scheduleWeekOnly", value: "true" });
|
|
if (patch.targetWeek !== undefined) {
|
|
ops.push({ field: "targetWeek", value: patch.targetWeek });
|
|
}
|
|
if (patch.scheduledOn !== undefined) {
|
|
ops.push({ field: "scheduledDate", value: patch.scheduledOn });
|
|
}
|
|
return ops;
|
|
}
|
|
|
|
if (patch.scheduleWeekOnly === false) {
|
|
ops.push({ field: "scheduleWeekOnly", value: "false" });
|
|
}
|
|
if (patch.scheduledOn !== undefined) {
|
|
ops.push({ field: "scheduledDate", value: patch.scheduledOn });
|
|
}
|
|
if (patch.targetWeek !== undefined) {
|
|
ops.push({ field: "targetWeek", value: patch.targetWeek });
|
|
}
|
|
|
|
return ops;
|
|
}
|