mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-06 18:12:05 +00:00
32 lines
1.3 KiB
TypeScript
32 lines
1.3 KiB
TypeScript
|
|
import type { WorkOrderTableRow } from "@/domain/work-orders/types/work-order-table-row";
|
||
|
|
|
||
|
|
const SERVICE_PHRASE: Record<string, string> = {
|
||
|
|
"Scrubber Pit": "Scrubber Pit Augering",
|
||
|
|
"Backflow Preventers": "Backflow Preventer Testing",
|
||
|
|
"Domestic Backflow": "Domestic Backflow Testing",
|
||
|
|
"Tank / Water Heater": "Tank / Water Heater Inspection",
|
||
|
|
"Pressure Reducing Valve": "Pressure Reducing Valve Service",
|
||
|
|
"Pumping Systems": "Pumping System Maintenance",
|
||
|
|
"HVAC Inspection": "HVAC Inspection",
|
||
|
|
Electrical: "Electrical Inspection",
|
||
|
|
Plumbing: "Plumbing Service",
|
||
|
|
"Door / Hardware": "Door / Hardware Service",
|
||
|
|
"Floor Drain Backing Up": "Floor Drain Augering",
|
||
|
|
"Parking Lot Lighting": "Parking Lot Lighting Service",
|
||
|
|
"Mens Restroom Camera Line": "Restroom Camera Line Service",
|
||
|
|
"Assess Window Leaks": "Window Leak Assessment",
|
||
|
|
};
|
||
|
|
|
||
|
|
const FREQ_CYCLE = ["13 Week", "26 Week", "52 Week"];
|
||
|
|
|
||
|
|
function hashNum(s: string, mod: number): number {
|
||
|
|
let h = 0;
|
||
|
|
for (let i = 0; i < s.length; i++) h = (h * 31 + s.charCodeAt(i)) >>> 0;
|
||
|
|
return h % mod;
|
||
|
|
}
|
||
|
|
|
||
|
|
export function serviceTitle(row: Pick<WorkOrderTableRow, "pm" | "woNumber">): string {
|
||
|
|
const phrase = SERVICE_PHRASE[row.pm] ?? row.pm;
|
||
|
|
return `Amer-Building ${phrase} — ${FREQ_CYCLE[hashNum(row.woNumber, FREQ_CYCLE.length)]}`;
|
||
|
|
}
|