Phase 4: scoreboard page, public API and realtime refresh

- buildScoreboardPayload is the single place deciding what the public may
  see: visible, frozen (snapshot scores, live current game), hidden (no
  scores, alphabetical) and reveal (unrevealed teams carry no score/order).
- GET /api/public/scoreboard/[token] validates the token, then loads the
  event with the service client in one parallel round trip.
- notify() pings sb/admin/game channels over Realtime's REST endpoint with
  no data; useRefreshChannel refetches immediately on a ping, throttles
  bursts, and falls back to a 10s poll, focus and reconnect.
- /s/[token]: FLIP rank animation, count-up totals, reduced motion,
  fullscreen, cursor hide and a connection indicator.
- Admin setup actions now notify, so renames and reorders show up live.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-03 14:19:03 +02:00
co-authored by Claude Opus 5.5
parent b60c9db4f4
commit 17eb76d036
18 changed files with 977 additions and 8 deletions
+12 -1
View File
@@ -4,6 +4,7 @@ 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 { buttonClass } from "@/components/ui/button";
import { requireAdmin } from "@/lib/auth";
import { loadEventSetup } from "@/lib/queries/event";
import { idSchema } from "@/lib/tokens";
@@ -23,7 +24,17 @@ export default async function EventSetupPage(props: PageProps<"/admin/events/[ev
<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 className="mt-1 flex flex-wrap items-center justify-between gap-3">
<h1 className="font-display text-4xl font-bold">{event.name}</h1>
<a
href={`/s/${event.scoreboard_token}`}
target="_blank"
rel="noreferrer"
className={buttonClass("secondary")}
>
Open scoreboard
</a>
</div>
</div>
<section className="rounded-lg border border-ink/15 bg-white p-4">