import type { GiftCard, GiftCardTrxn } from "@/app/lib/types"; // Display labels for the Gift Cards page (add-gift-card-core). export const STATUS_LABEL: Record = { ACTIVE: "CatActive", EXPIRED: "GcStatusExpired", DEACTIVATED: "GcStatusDeactivated", }; export const STATUS_TONE: Record = { ACTIVE: "positive", EXPIRED: "warning", DEACTIVATED: "neutral", }; export const SOURCE_LABEL: Record = { ADMIN: "Admin", ONLINE: "GcSourceOnline", COUNTER: "GcSourceCounter" }; export const TRXN_LABEL: Record = { ISSUE: "GcIssued", SPEND: "GcTrxnSpent", REFUND: "GcTrxnRefund", TRANSFER_OUT: "GcTrxnMovedToWallet", ADJUST_IN: "GcTrxnAdjustIn", ADJUST_OUT: "GcTrxnAdjustOut", DEACTIVATE: "GcStatusDeactivated", EXTEND: "GcTrxnExpiryExtended", }; const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; /** The day after an ISO date: the earliest new expiry the server accepts (it must be later than the current one). */ export function nextDay(iso: string): string { const d = new Date(`${iso.slice(0, 10)}T00:00:00Z`); d.setUTCDate(d.getUTCDate() + 1); return d.toISOString().slice(0, 10); } /** "2029-10-06" or "2029-10-06T09:00:00" → "6 Oct 2029". */ export function formatDate(value: string | null | undefined): string { if (!value) return "—"; const [y, m, d] = value.slice(0, 10).split("-").map(Number); return y && m && d ? `${d} ${MONTHS[m - 1]} ${y}` : value; }