import Link from "next/link"; import { notFound } from "next/navigation"; import { CohostsEditor } from "@/components/admin/cohosts-editor"; import { EventDetailsForm } from "@/components/admin/event-details-form"; import { GamesEditor } from "@/components/admin/games-editor"; import { SharePanel } from "@/components/admin/share-panel"; import { TeamsEditor } from "@/components/admin/teams-editor"; import { buttonClass } from "@/components/ui/button"; 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, userId } = await requireAdmin(); const { eventId } = await props.params; if (!idSchema.safeParse(eventId).success) notFound(); const [setup, cohosts] = await Promise.all([ loadEventSetup(supabase, eventId), supabase.from("event_cohosts").select("id, email").eq("event_id", eventId).order("created_at"), ]); if (!setup) notFound(); if (cohosts.error) throw new Error(`Could not load the co-hosts: ${cohosts.error.message}`); const { event, teams, games } = setup; return (