From 639fe0e202f9b08eb7f8e069022a013ff1e0206d Mon Sep 17 00:00:00 2001 From: thesn10 <38666407+thesn10@users.noreply.github.com> Date: Thu, 2 Jul 2026 22:20:35 +0200 Subject: [PATCH] Add status helpers --- app/src/lib/status.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 app/src/lib/status.ts diff --git a/app/src/lib/status.ts b/app/src/lib/status.ts new file mode 100644 index 0000000..c1a7c7a --- /dev/null +++ b/app/src/lib/status.ts @@ -0,0 +1,26 @@ +import type { OrderStatus } from "@/data/mock"; + +export type StatusColor = "default" | "accent" | "success" | "warning" | "danger"; + +export interface StatusInfo { + label: string; + color: StatusColor; +} + +const ORDER_STATUS_INFO: Record = { + AwaitingConfirm: { label: "Awaiting Confirm", color: "warning" }, + Active: { label: "Active", color: "accent" }, + Complete: { label: "Complete", color: "success" }, + Cancelled: { label: "Cancelled", color: "default" }, + Disputed: { label: "Disputed", color: "danger" }, +}; + +export function orderStatusInfo(status: OrderStatus): StatusInfo { + return ORDER_STATUS_INFO[status]; +} + +export function availabilityInfo(qty: number): StatusInfo { + if (qty === 0) return { label: "Out of Stock", color: "default" }; + if (qty <= 3) return { label: `Only ${qty} left!`, color: "warning" }; + return { label: `${qty} in stock`, color: "success" }; +}