Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
64 lines
1.8 KiB
TypeScript
64 lines
1.8 KiB
TypeScript
// add-event-ticket-orders: what a TICKETS block, a ticket request and the public order page carry.
|
|
|
|
import { publicCall } from "@/app/lib/services/publicRegistration";
|
|
|
|
export interface PublicTicketType {
|
|
id: number;
|
|
name: string;
|
|
priceSen: number;
|
|
left: number;
|
|
state: "ON_SALE" | "SOLD_OUT" | "ENDED";
|
|
}
|
|
|
|
export interface TicketsInfo {
|
|
eventName: string;
|
|
startDate: string | null;
|
|
endDate: string;
|
|
location: string | null;
|
|
companyName: string;
|
|
notice: { id: number; textEn: string; textMs: string };
|
|
types: PublicTicketType[];
|
|
}
|
|
|
|
export interface OrderLine {
|
|
name: string;
|
|
unitPriceSen: number;
|
|
quantity: number;
|
|
}
|
|
|
|
/** A request's answer: a token only when an order was saved (the honeypot gets a thank-you without one). */
|
|
export interface TicketRequestResult {
|
|
eventName: string;
|
|
reference?: string;
|
|
token?: string;
|
|
status?: "AWAITING" | "PAID";
|
|
totalSen?: number;
|
|
holdUntil?: string | null;
|
|
lines?: OrderLine[];
|
|
paymentInstructions?: string;
|
|
}
|
|
|
|
export interface PublicOrder {
|
|
reference: string;
|
|
status: "AWAITING" | "PAID" | "CANCELLED" | "EXPIRED";
|
|
buyerName: string;
|
|
totalSen: number;
|
|
createdAt: string;
|
|
lines: OrderLine[];
|
|
eventName: string;
|
|
startDate: string | null;
|
|
endDate: string | null;
|
|
location: string | null;
|
|
holdUntil?: string | null;
|
|
paymentInstructions?: string | null;
|
|
}
|
|
|
|
/** A Malaysia wall-clock time from the server ("2027-01-13T12:00:00") as "13 Jan 2027, 12:00". */
|
|
export function when(s: string | null | undefined): string {
|
|
if (!s) return "";
|
|
const d = new Date(s);
|
|
return Number.isNaN(d.getTime()) ? s : d.toLocaleString("en-GB", { day: "numeric", month: "short", year: "numeric", hour: "2-digit", minute: "2-digit" });
|
|
}
|
|
|
|
export const getPublicOrder = (token: string) => publicCall<PublicOrder>(`/api/public/orders/${encodeURIComponent(token)}`);
|