'use client' import { useQuery, gql } from '@/lib/graphql/hooks' import { useEffect } from 'react' import Link from 'next/link' import { TeamFlag } from '@/components/team-flag' const HISTORY_QUERY = gql` query History { tournaments { year host winner runnerUp thirdPlace fourthPlace totalGoals matchesCount teamsCount avgGoalsPerGame topScorers(limit: 1) { playerName goals team { name iso2 } } } } ` interface Tournament { year: number; host: string; winner?: string | null; runnerUp?: string | null thirdPlace?: string | null; fourthPlace?: string | null totalGoals?: number | null; matchesCount?: number | null; teamsCount?: number | null avgGoalsPerGame?: string | number | null topScorers: Array<{ playerName: string; goals: number; team?: { name: string; iso2?: string | null } | null }> } export default function HistoryPage() { useEffect(() => { document.title = 'History · World Cup' }, []) const { data, loading } = useQuery(HISTORY_QUERY) const tournaments: Tournament[] = data?.tournaments ?? [] const is2026InProgress = !tournaments.find(t => t.year === 2026)?.winner return (

World Cup History

Every edition — Uruguay 1930 through 2026 · {tournaments.length} tournaments

{loading && !data && (
{Array.from({ length: 24 }).map((_, i) => (
))}
)}
{tournaments.map(t => { const inProgress = t.year === 2026 && is2026InProgress const topScorer = t.topScorers?.[0] return (
{/* Year watermark */}
{t.year}
{t.year}
{t.host}
{inProgress ?
IN PROGRESS
: t.winner && (
{t.winner}
)}
{!inProgress && t.winner && t.runnerUp && (
{t.winner} def. {t.runnerUp}
)}
{t.totalGoals != null && ⚽ {t.totalGoals}} {t.matchesCount != null && 🗓 {t.matchesCount} games} {t.teamsCount != null && 🏳 {t.teamsCount} teams}
{topScorer && (
Golden Boot: {topScorer.playerName} ({topScorer.goals}⚽)
)}
) })}
) }