import type { CompletionDocStatus } from "@/domain/work-orders/types/work-order-table-row"; /** UI uses `NN`; board/API enum uses `NotNeeded` (also numeric 3). */ export function mapDocStatusToApi(value: string): string { if (value === "NN") { return "NotNeeded"; } return value; } export function readDocStatusFromRecord(record: Record): CompletionDocStatus { const rawValue = record.docStatus ?? record.DocStatus ?? record.completionDoc ?? record.CompletionDoc; if (typeof rawValue === "number") { if (rawValue === 1) return "Yes"; if (rawValue === 2) return "No"; if (rawValue === 3) return "NN"; } if (typeof rawValue === "string") { if (rawValue === "Yes" || rawValue === "No" || rawValue === "NN") { return rawValue; } if (rawValue === "NotNeeded") { return "NN"; } } return ""; }