Files
co-lite/solvway-admin-portal/app/lib/services/adminGuests.ts
T
ngqileandClaude Opus 5.5 b4d36175d3 fix: paste guests, form errors, send feedback, check-in errors, invite recipients
Found by the manual e2e of the production build:
- paste guests preview counted an array, so it read "[object Object]"
  and never offered Save guests;
- New event and Add user errors now clear when the field is fixed;
- "Send to all unsent" says when nothing was unsent;
- the check-in lookup shows an error on an empty submit and carries the
  typed email or mobile into the walk-in form;
- invitation emails sent over Pub/Sub now save their recipient's link,
  so the Emails page shows the recipient.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-12-02 01:38:37 +08:00

59 lines
2.0 KiB
TypeScript

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;
total: number;
capacity: number | null;
}
const base = (uuid: string) => `/api/events/${encodeURIComponent(uuid)}`;
export const listGuests = (uuid: string) => apiGet<EventGuest[]>(`${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<AddGuestsResult> => {
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<unknown>(`${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<Attendance>(`${base(uuid)}/attendance`);