import Link from 'next/link' import { TeamFlag } from './team-flag' import { LiveBadge } from './live-badge' interface Team { name: string; iso2?: string | null; slug?: string | null } interface Match { id: number year: number round: string group?: string | null date?: string | null time?: string | null team1: Team team2: Team scoreFt?: number[] | null scoreEt?: number[] | null scoreP?: number[] | null isLive: boolean } function formatDate(d: string) { return new Date(d).toLocaleDateString('en-GB', { day: 'numeric', month: 'short', year: 'numeric' }) } export function MatchCard({ match, compact = false }: { match: Match; compact?: boolean }) { const ft = match.scoreFt const hasScore = ft != null // Winner: penalties first, then ET, then FT const decisive = match.scoreP ?? match.scoreEt ?? ft const winner = decisive ? (decisive[0] > decisive[1] ? 'home' : decisive[0] < decisive[1] ? 'away' : 'draw') : null if (compact) { return (
{match.round}{match.group ? ` · ${match.group}` : ''} · {match.date ? formatDate(match.date) : ''}
{match.team1.name}
{hasScore ? match.scoreP ? `${match.scoreP[0]} – ${match.scoreP[1]}` : match.scoreEt ? `${match.scoreEt[0]} – ${match.scoreEt[1]}` : `${ft![0]} – ${ft![1]}` : match.isLive ? : '–'}
{match.scoreP && (
{ft![0]}–{ft![1]} a.e.t.
)} {match.scoreEt && !match.scoreP && (
a.e.t.
)}
{match.team2.name}
{match.scoreEt && !match.scoreP && (
a.e.t.
)}
) } const matchHref = `/tournaments/${match.year}#match-${match.id}` return (
{match.isLive &&
}
{match.team1.name}
{hasScore ? match.scoreP ? `${match.scoreP[0]}–${match.scoreP[1]}` : match.scoreEt ? `${match.scoreEt[0]}–${match.scoreEt[1]}` : `${ft![0]}–${ft![1]}` : '?–?'}
{match.scoreP && (
{ft![0]}–{ft![1]} a.e.t.
)} {match.scoreEt && !match.scoreP && (
{ft![0]}–{ft![1]} (a.e.t.)
)}
{match.round}
{match.date ? formatDate(match.date) : ''}
{match.team2.name}
) }