import { apiDelete, apiGet, apiPost } from "@/app/lib/clientApi"; export interface EventGuest { id: number; name: string; mobileE164: string | null; email: string | null; companyName: string | null; salespersonUserId: number | null; salespersonName: string | null; /** Absent without BO_EVENT_GUESTS. */ token?: string; invitedAt: string; inviteSentCount: number; registeredAt: string | null; attended: boolean; eventLeadUuid: string | null; } export interface GuestInput { name: string; mobile: string; email: string; companyName: string; salespersonUserId?: number; } export interface GuestRejection { index: number; code: string; field: string | null; message: string; } export interface AddGuestsResult { added: number; rejected: GuestRejection[]; } export interface Attendance { invited: number; cap: number | null; registered: number; attended: number; walkIns: number; /** add-event-ticket-orders: seats of awaiting and paid ticket orders; part of the total. */ heldTickets: number; total: number; capacity: number | null; } const base = (uuid: string) => `/api/events/${encodeURIComponent(uuid)}`; export const listGuests = (uuid: string) => apiGet(`${base(uuid)}/guests`); // The API lists the added guests; the screen only needs how many. export const addGuests = async (uuid: string, guests: GuestInput[], preview: boolean): Promise => { const res = await apiPost<{ added?: unknown[]; rejected: GuestRejection[] }>(`${base(uuid)}/guests${preview ? "?preview=true" : ""}`, { guests }); return { added: res.added?.length ?? 0, rejected: res.rejected }; }; export const removeGuest = (uuid: string, id: number) => apiDelete(`${base(uuid)}/guests/${id}`); export const sendInvites = (uuid: string, target: { guestIds: number[] } | { allUnsent: true }) => apiPost<{ sent: number; skippedNoEmail: number }>(`${base(uuid)}/guests/send`, target); export const getCheckin = (uuid: string) => apiGet<{ token: string }>(`${base(uuid)}/checkin`); export const getAttendance = (uuid: string) => apiGet(`${base(uuid)}/attendance`);