Files
co-lite/solvway-admin-portal/app/gift-cards/giftCardLabels.ts
T
ngqileandClaude Opus 5.5 5ee51d1913 chore: copy kept Tastefully modules and portals into Co-Lite
Backend modules from tastefully 8bd93d15: core-libs, core-session,
api-gateway, mobile-api, services-auth, services-system,
services-counter, services-member, services-log, services-email.
solvway-admin-portal from babyboo f64d096ea, solvway-customer-portal
from tastefully 8bd93d15. Copied as tracked files only.

Literal secrets replaced with environment placeholders:
- services-email: SMTP_PASSWORD, MAILGUN_API_KEY, SENDGRID_API_KEY,
  MAILJET_API_KEY, MAILJET_SECRET_KEY (optional, empty default)
- services-system: JUMIO_TOKEN, JUMIO_SECRET (optional)
- services-auth: USER_AUTH_API_SECRET (required); commented JWT secret removed
- core-libs: JWT_TOKEN default removed (required), XXL_JOB_TOKEN default
  removed, ipgeolocation key read from IPGEOLOCATION_API_KEY
- services-system EkycAppConfig: commented Jumio credentials removed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-11-26 15:55:45 +08:00

45 lines
1.6 KiB
TypeScript

import type { GiftCard, GiftCardTrxn } from "@/app/lib/types";
// Display labels for the Gift Cards page (add-gift-card-core).
export const STATUS_LABEL: Record<GiftCard["status"], string> = {
ACTIVE: "CatActive",
EXPIRED: "GcStatusExpired",
DEACTIVATED: "GcStatusDeactivated",
};
export const STATUS_TONE: Record<GiftCard["status"], "positive" | "warning" | "neutral"> = {
ACTIVE: "positive",
EXPIRED: "warning",
DEACTIVATED: "neutral",
};
export const SOURCE_LABEL: Record<string, string> = { ADMIN: "Admin", ONLINE: "GcSourceOnline", COUNTER: "GcSourceCounter" };
export const TRXN_LABEL: Record<GiftCardTrxn["trxnType"], string> = {
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;
}