Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
20 lines
1.4 KiB
TypeScript
20 lines
1.4 KiB
TypeScript
import { publicCall, type RegistrationBody, type RegistrationInfo } from "@/app/lib/services/publicRegistration";
|
|
|
|
export type InviteInfo = RegistrationInfo & {
|
|
guest: { name: string | null; mobile: string | null; email: string | null; companyName: string | null };
|
|
state: "OPEN" | "REGISTERED" | "CHECKIN" | "CHECKED_IN";
|
|
};
|
|
export type CheckinState = (RegistrationInfo & { state: "OPEN" }) | { state: "NOT_YET" | "ENDED"; startDate: string };
|
|
|
|
const invite = (token: string) => `/api/public/invite/${encodeURIComponent(token)}`;
|
|
const checkin = (token: string) => `/api/public/checkin/${encodeURIComponent(token)}`;
|
|
const post = (body?: unknown) => ({ method: "POST", body: JSON.stringify(body ?? {}) });
|
|
|
|
export const getInvite = (token: string) => publicCall<InviteInfo>(invite(token));
|
|
export const submitInvite = (token: string, body: RegistrationBody) => publicCall<{ eventName: string }>(invite(token), post(body));
|
|
export const inviteCheckin = (token: string) => publicCall<{ firstName: string }>(`${invite(token)}/checkin`, post());
|
|
export const getCheckin = (token: string) => publicCall<CheckinState>(checkin(token));
|
|
export const lookupCheckin = (token: string, value: string) =>
|
|
publicCall<{ result: "CHECKED_IN"; firstName: string } | { result: "FORM" }>(`${checkin(token)}/lookup`, post({ value }));
|
|
export const registerWalkIn = (token: string, body: RegistrationBody) => publicCall<{ eventName: string }>(`${checkin(token)}/register`, post(body));
|