'use client' import { useQuery, gql } from '@/lib/graphql/hooks' 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 }> } function HostIso(host: string): string { const map: Record = { 'Uruguay': 'uy', 'Italy': 'it', 'France': 'fr', 'Brazil': 'br', 'Switzerland': 'ch', 'Sweden': 'se', 'Chile': 'cl', 'England': 'gb-eng', 'Mexico': 'mx', 'Germany': 'de', 'Argentina': 'ar', 'Spain': 'es', 'South Korea / Japan': 'kr', 'South Africa': 'za', 'Russia': 'ru', 'Qatar': 'qa', 'USA': 'us', 'USA / Canada / Mexico': 'us', } return map[host] ?? 'un' } export default function HistoryPage() { 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}โšฝ)
)}
) })}
) }