mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-03 22:33:13 +00:00
28 lines
872 B
TypeScript
28 lines
872 B
TypeScript
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<string, unknown>): 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 "";
|
|
}
|