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 5024ab7241
commit dc4d2fff41
32 changed files with 375 additions and 175 deletions
@@ -6,8 +6,16 @@ import { apiFetch } from "@/lib/api";
import { isMinorOn } from "@/components/shared/AttendeeNamesEditor";
import { errorMessage } from "@/lib/utils";
type TransferTicket = { id: string; isUsed?: boolean; quantity?: number; usages?: unknown[] };
type TransferEvent = {
startDate?: string;
allowTicketTransfer?: boolean;
requiresParentalConsent?: boolean;
collectGender?: boolean;
};
/** Whether to offer "Transfer" on a ticket (the server checks the rules again). */
export function canOfferTransfer(ticket: any, event: any, isSupervisor = false): boolean {
export function canOfferTransfer(ticket: TransferTicket | null | undefined, event: TransferEvent | null | undefined, isSupervisor = false): boolean {
if (!ticket || !event) return false;
if ((ticket.usages || []).length > 0 || ticket.isUsed) return false;
if (event.startDate && new Date(event.startDate) <= new Date()) return false;
@@ -20,8 +28,8 @@ export function canOfferTransfer(ticket: any, event: any, isSupervisor = false):
* to the details typed, and the ticket only moves (with a new QR code) once they accept.
*/
export function TransferTicketModal({ ticket, event, token, onClose, onDone }: {
ticket: any;
event: any;
ticket: TransferTicket;
event: TransferEvent | null | undefined;
token: string;
onClose: () => void;
onDone: (message: string) => void;