Add shared API types and type the smaller frontend pages

Expand src/types with User, Event, EventOption, Registration, Payment,
Ticket, paginated results and dashboard stats, modelled on the Prisma
schema. apiFetch now defaults to unknown instead of any. Dashboard
loaders are wrapped in useCallback so their effects can list them as
dependencies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-21 11:10:01 +02:00
co-authored by Claude Opus 5.5
parent 619b5b9a93
commit 545f3d913e
32 changed files with 375 additions and 175 deletions
@@ -12,7 +12,7 @@ const CONSENT_LABEL: Record<string, { text: string; cls: string }> = {
declined: { text: "consent declined", cls: "text-red-700" },
};
type Attendee = {
export type Attendee = {
id: string; eventOptionId: string; variantId: string | null; name: string; email: string | null; phone: string | null;
dateOfBirth?: string | null; gender?: string | null; parentName?: string | null; parentEmail?: string | null; parentPhone?: string | null;
ticket?: { id: string; isUsed: boolean } | null;
@@ -23,20 +23,41 @@ type Row = {
dateOfBirth: string; gender: string; parentName: string; parentEmail: string; parentPhone: string;
};
// The parts of a registration (with its attendees, options and event) this panel reads.
export type AttendeesRegistration = {
id: string;
ticketDelivery?: "payer" | "each";
attendees?: Attendee[];
event?: {
requiresParentalConsent?: boolean;
collectGender?: boolean;
allowNamedAttendees?: boolean;
startDate?: string;
} | null;
registrationOptions?: {
eventOptionId: string;
variantId?: string | null;
quantity: number;
eventOption?: { name?: string; isMainTicket?: boolean } | null;
variant?: { name?: string } | null;
}[];
formResponses?: { attendeeId?: string | null }[];
};
/**
* Named attendees on a registration (group tickets): shows who each main-ticket place
* is for, and lets the payer (or staff) name places, change details, choose where the
* tickets go, and send an attendee the link to their own form.
*/
export function AttendeesPanel({ registration, token, canEdit, hasForm, onSaved, onMessage }: {
registration: any;
registration: AttendeesRegistration;
token: string;
canEdit: boolean;
hasForm: boolean;
onSaved: () => void;
onMessage: (msg: string) => void;
}) {
const attendees: Attendee[] = registration.attendees || [];
const attendees = useMemo<Attendee[]>(() => registration.attendees || [], [registration.attendees]);
const youth = !!registration.event?.requiresParentalConsent;
const collectGender = !!registration.event?.collectGender;
const eventStart: string | undefined = registration.event?.startDate;
@@ -117,7 +138,7 @@ export function AttendeesPanel({ registration, token, canEdit, hasForm, onSaved,
}
};
const answered = new Set((registration.formResponses || []).map((r: any) => r.attendeeId).filter(Boolean));
const answered = new Set((registration.formResponses || []).map((r) => r.attendeeId).filter(Boolean));
const resendConsent = async (requestId: string) => {
try {