init
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
export const NO_BIKE = "No bike found for this number.";
|
||||
export const NOT_IN_WORKSHOP = "This bike is not in the workshop.";
|
||||
|
||||
export const STAGE_LABELS: Record<string, string> = {
|
||||
received: "Received",
|
||||
diagnostic: "Diagnostic",
|
||||
in_repair: "In Repair",
|
||||
quality_check: "Quality Check",
|
||||
ready: "Ready",
|
||||
billed: "Billed",
|
||||
};
|
||||
|
||||
export function stageLabel(stage: string): string {
|
||||
return STAGE_LABELS[stage] ?? stage;
|
||||
}
|
||||
|
||||
export type JobPick = {
|
||||
id: string;
|
||||
stage: string;
|
||||
createdAt: string;
|
||||
};
|
||||
|
||||
/** Newest non-deleted job that is not billed. Caller already dropped deleted rows. */
|
||||
export function pickWorkshopJob(jobs: JobPick[]): JobPick | null {
|
||||
const open = jobs.filter((job) => job.stage !== "billed");
|
||||
open.sort((a, b) => {
|
||||
const byTime = b.createdAt.localeCompare(a.createdAt);
|
||||
if (byTime !== 0) return byTime;
|
||||
return b.id.localeCompare(a.id);
|
||||
});
|
||||
return open[0] ?? null;
|
||||
}
|
||||
|
||||
export type BikeStatus = {
|
||||
registration: string;
|
||||
make: string;
|
||||
model: string;
|
||||
inWorkshop: boolean;
|
||||
stageLabel: string | null;
|
||||
stageAt: string | null;
|
||||
};
|
||||
|
||||
export type StatusResult = {
|
||||
message: string | null;
|
||||
error: string | null;
|
||||
bikes: BikeStatus[];
|
||||
};
|
||||
Reference in New Issue
Block a user