Phase 3: admin magic-link auth and event setup screens

- /login sends a Supabase magic link (admin emails only); /auth/confirm
  completes sign-in; proxy.ts guards /admin and every server action
  re-checks with requireAdmin(), since actions are plain POST endpoints.
- /admin lists, creates, duplicates and deletes events.
- /admin/events/[eventId] edits teams (colour, order) and games with
  criteria, presets and notes. All input goes through zod schemas that
  mirror the database constraints so errors read as plain sentences.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-03 13:47:36 +02:00
co-authored by Claude Opus 5.5
parent 0c66e9b80e
commit b60c9db4f4
30 changed files with 1930 additions and 2 deletions
+50
View File
@@ -0,0 +1,50 @@
import Link from "next/link";
import { notFound } from "next/navigation";
import { EventDetailsForm } from "@/components/admin/event-details-form";
import { GamesEditor } from "@/components/admin/games-editor";
import { TeamsEditor } from "@/components/admin/teams-editor";
import { requireAdmin } from "@/lib/auth";
import { loadEventSetup } from "@/lib/queries/event";
import { idSchema } from "@/lib/tokens";
export default async function EventSetupPage(props: PageProps<"/admin/events/[eventId]">) {
const { supabase } = await requireAdmin();
const { eventId } = await props.params;
if (!idSchema.safeParse(eventId).success) notFound();
const setup = await loadEventSetup(supabase, eventId);
if (!setup) notFound();
const { event, teams, games } = setup;
return (
<div className="flex flex-col gap-8">
<div>
<Link href="/admin" className="text-sm underline underline-offset-4">
← All game nights
</Link>
<h1 className="mt-1 font-display text-4xl font-bold">{event.name}</h1>
</div>
<section className="rounded-lg border border-ink/15 bg-white p-4">
<h2 className="text-xl font-bold">Details</h2>
<EventDetailsForm
key={event.updated_at}
eventId={event.id}
name={event.name}
eventDate={event.event_date ?? ""}
/>
</section>
<section className="rounded-lg border border-ink/15 bg-white p-4">
<h2 className="text-xl font-bold">Teams</h2>
<TeamsEditor eventId={event.id} teams={teams} />
</section>
<section>
<h2 className="text-xl font-bold">Games</h2>
<GamesEditor eventId={event.id} games={games} />
</section>
</div>
);
}