Files
game-scoreboard/src/app/login/login-form.tsx
T
joshuaandClaude Opus 5.5 f1b3a862f8 Phase 8: share panel, polish, accessibility and deploy config
- Share links section: scoreboard link, every judged game's judge links
  and open link with QR codes, and 'Copy all judge links' as plain text
  for WhatsApp. Warns when links point at localhost.
- Error and not-found pages with plain-language copy; a real start page.
- Accessibility: darker 'alert strong' red for text and white-on-red
  (Alert was 4.0:1 on white), no text below 70% ink, 44px block buttons
  and link targets, scoreboard status stays readable when idle.
- vercel.json pins functions to Dublin next to the West EU database;
  README documents deployment and pre-game-night checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 16:02:29 +02:00

38 lines
1.2 KiB
TypeScript

"use client";
import { useActionState } from "react";
import { Button } from "@/components/ui/button";
import { Field, inputClass } from "@/components/ui/field";
import { sendMagicLink, type LoginState } from "./actions";
const initialState: LoginState = { status: "idle", message: "" };
export function LoginForm({ initialError }: { initialError: string | null }) {
const [state, formAction, pending] = useActionState(sendMagicLink, initialState);
const error = state.status === "error" ? state.message : state.status === "idle" ? initialError : null;
return (
<form action={formAction} className="flex flex-col gap-4">
<Field label="Email">
<input
name="email"
type="email"
autoComplete="email"
required
className={inputClass}
placeholder="you@example.com"
/>
</Field>
<Button type="submit" disabled={pending}>
{pending ? "Sending…" : "Send sign-in link"}
</Button>
<p role="status" aria-live="polite" className="min-h-6">
{state.status === "sent" && <span className="font-bold text-ink">{state.message}</span>}
{error && <span className="font-bold text-alert-strong">{error}</span>}
</p>
</form>
);
}