'use client' import { useQuery, gql } from '@/lib/graphql/hooks' import { useEffect } from 'react' import Link from 'next/link' import { TeamFlag } from '@/components/team-flag' import { LiveBadge } from '@/components/live-badge' import { MatchCard } from '@/components/match-card' const HOME_QUERY = gql` query Home { tournamentStats { totalTournaments totalMatches totalGoals avgGoalsPerGame } liveMatches { id year round group date time isLive scoreFt scoreEt scoreP isQualiPlayoff team1 { name iso2 } team2 { name iso2 } } recentMatches(limit: 9) { id year round group date time isLive isQualiPlayoff scoreFt scoreEt scoreP team1 { name iso2 } team2 { name iso2 } } upcomingMatches(limit: 9) { id year round group date time isLive isQualiPlayoff scoreFt team1 { name iso2 } team2 { name iso2 } } topScorers(year: 2026, limit: 8) { playerName goals penalties ownGoals team { name iso2 } } tournament(year: 2026) { year totalGoals matchesCount avgGoalsPerGame } } ` function SectionHeader({ label }: { label: string }) { return (
{label}
) } function StatPill({ label, value }: { label: string; value: string | number }) { return (
{label}
{value ?? '–'}
) } interface UpcomingMatch { id: number; year: number; time?: string | null; date?: string | null team1: { name: string; iso2?: string | null } team2: { name: string; iso2?: string | null } } function UpcomingFixture({ match }: { match: UpcomingMatch }) { const time = match.time?.split(' ')[0] ?? '' return (
{match.team1.name} vs {match.team2.name}
{time &&
{time}
}
) } interface ScorerEntry { playerName: string; goals: number; penalties: number team?: { name: string; iso2?: string | null } | null } interface MatchData { id: number; year: number; round: string; group?: string | null date?: string | null; time?: string | null; isLive: boolean; isQualiPlayoff: boolean scoreFt?: number[] | null; scoreEt?: number[] | null; scoreP?: number[] | null team1: { name: string; iso2?: string | null } team2: { name: string; iso2?: string | null } } export default function HomePage() { const { data, loading } = useQuery(HOME_QUERY, { pollInterval: 60_000 }) useEffect(() => { document.title = 'World Cup' }, []) const stats = data?.tournamentStats const live: MatchData[] = data?.liveMatches ?? [] const recent: MatchData[] = data?.recentMatches ?? [] const upcoming: UpcomingMatch[] = data?.upcomingMatches ?? [] const scorers: ScorerEntry[] = data?.topScorers ?? [] const wc2026 = data?.tournament const maxGoals = Math.max(...scorers.map(s => s.goals), 1) return (
{/* ── Hero ── */}
{live.length > 0 ? :
World Cup 2026 · In Progress
}

World Cup 2026

USA · Canada · Mexico  ·  11 June – 19 July 2026 · 48 Teams

{stats ? <> {wc2026 && <> } : [1,2,3,4].map(i => (
))}
{/* Live matches */} {live.length > 0 && (
{live.map(m => )}
)} {/* Latest result */} {recent.length > 0 && (
)} {/* Recent grid */} {recent.length > 1 && (
{recent.slice(1).map(m => )}
)} {/* Upcoming */} {upcoming.length > 0 && (
{upcoming.map(m => )}
)} {/* Golden Boot 2026 */} {scorers.length > 0 && (
{scorers.map((s, i) => (
{i + 1} {s.team && }
{s.playerName}
{s.team?.name}{s.penalties > 0 ? ` · ${s.penalties}P` : ''}
{s.goals}
))}

View all-time top scorers →

)} {loading && !data && (
Loading live World Cup data…
)}
) }