2026-06-14 15:36:44 +02:00
|
|
|
|
import Link from 'next/link'
|
|
|
|
|
|
import { TeamFlag } from './team-flag'
|
|
|
|
|
|
import { LiveBadge } from './live-badge'
|
|
|
|
|
|
|
2026-06-14 21:07:56 +02:00
|
|
|
|
interface Team { name: string; iso2?: string | null; slug?: string | null }
|
2026-06-14 15:36:44 +02:00
|
|
|
|
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
|
2026-06-14 21:07:56 +02:00
|
|
|
|
// Winner: penalties first, then ET, then FT
|
|
|
|
|
|
const decisive = match.scoreP ?? match.scoreEt ?? ft
|
2026-06-14 19:39:01 +02:00
|
|
|
|
const winner = decisive ? (decisive[0] > decisive[1] ? 'home' : decisive[0] < decisive[1] ? 'away' : 'draw') : null
|
2026-06-14 15:36:44 +02:00
|
|
|
|
|
|
|
|
|
|
if (compact) {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<Link href={`/tournaments/${match.year}#match-${match.id}`} className="block">
|
2026-06-15 18:08:23 +02:00
|
|
|
|
<div className="glass-card rounded-xl p-3.5 hover:border-green/[22%] transition-colors">
|
|
|
|
|
|
<div className="text-[9px] text-green-muted tracking-[0.1em] uppercase mb-2.5">
|
2026-06-14 15:36:44 +02:00
|
|
|
|
{match.round}{match.group ? ` · ${match.group}` : ''} · {match.date ? formatDate(match.date) : ''}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
|
<div className="flex-1 flex items-center gap-2 overflow-hidden">
|
|
|
|
|
|
<TeamFlag name={match.team1.name} iso2={match.team1.iso2} size="sm" />
|
2026-06-15 18:08:23 +02:00
|
|
|
|
<span className={`text-sm font-medium truncate ${winner === 'home' ? 'text-text' : 'text-green-mid'}`}>
|
2026-06-14 15:36:44 +02:00
|
|
|
|
{match.team1.name}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
2026-06-14 19:39:01 +02:00
|
|
|
|
<div className="flex-shrink-0 min-w-[52px] text-center">
|
2026-06-15 18:08:23 +02:00
|
|
|
|
<div className="font-['Bebas_Neue'] text-xl text-green">
|
2026-06-14 19:39:01 +02:00
|
|
|
|
{hasScore
|
|
|
|
|
|
? match.scoreP
|
|
|
|
|
|
? `${match.scoreP[0]} – ${match.scoreP[1]}`
|
2026-06-14 21:07:56 +02:00
|
|
|
|
: match.scoreEt
|
|
|
|
|
|
? `${match.scoreEt[0]} – ${match.scoreEt[1]}`
|
|
|
|
|
|
: `${ft![0]} – ${ft![1]}`
|
2026-06-14 19:39:01 +02:00
|
|
|
|
: match.isLive ? <LiveBadge label="•" /> : '–'}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
{match.scoreP && (
|
2026-06-15 18:08:23 +02:00
|
|
|
|
<div className="text-[8px] text-green-muted leading-none">
|
2026-06-14 19:39:01 +02:00
|
|
|
|
{ft![0]}–{ft![1]} a.e.t.
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)}
|
2026-06-14 21:07:56 +02:00
|
|
|
|
{match.scoreEt && !match.scoreP && (
|
2026-06-15 18:08:23 +02:00
|
|
|
|
<div className="text-[8px] text-green-muted leading-none">a.e.t.</div>
|
2026-06-14 21:07:56 +02:00
|
|
|
|
)}
|
2026-06-14 15:36:44 +02:00
|
|
|
|
</div>
|
|
|
|
|
|
<div className="flex-1 flex items-center justify-end gap-2 overflow-hidden">
|
2026-06-15 18:08:23 +02:00
|
|
|
|
<span className={`text-sm font-medium truncate ${winner === 'away' ? 'text-text' : 'text-green-mid'}`}>
|
2026-06-14 15:36:44 +02:00
|
|
|
|
{match.team2.name}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
<TeamFlag name={match.team2.name} iso2={match.team2.iso2} size="sm" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2026-06-14 19:39:01 +02:00
|
|
|
|
{match.scoreEt && !match.scoreP && (
|
2026-06-15 18:08:23 +02:00
|
|
|
|
<div className="text-[9px] text-green-muted mt-1 text-center">a.e.t.</div>
|
2026-06-14 19:39:01 +02:00
|
|
|
|
)}
|
2026-06-14 15:36:44 +02:00
|
|
|
|
</div>
|
|
|
|
|
|
</Link>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-14 21:07:56 +02:00
|
|
|
|
const matchHref = `/tournaments/${match.year}#match-${match.id}`
|
|
|
|
|
|
|
2026-06-14 15:36:44 +02:00
|
|
|
|
return (
|
2026-06-15 18:08:23 +02:00
|
|
|
|
<div className="glass-card-hero rounded-2xl px-5 py-6 sm:px-9 sm:py-9 hover:border-green/45 transition-colors">
|
2026-06-14 21:07:56 +02:00
|
|
|
|
{match.isLive && <div className="mb-4"><LiveBadge label="Live Now" /></div>}
|
|
|
|
|
|
<div className="grid grid-cols-[1fr_auto_1fr] items-center gap-3 sm:gap-8">
|
|
|
|
|
|
<Link href={match.team1.slug ? `/teams/${match.team1.slug}` : matchHref}
|
2026-06-15 18:08:23 +02:00
|
|
|
|
className={`text-center block transition-colors hover:text-green ${winner === 'home' ? 'text-text' : 'text-green-sec'}`}>
|
2026-06-14 21:07:56 +02:00
|
|
|
|
<TeamFlag name={match.team1.name} iso2={match.team1.iso2} size="xl" className="mb-2" />
|
|
|
|
|
|
<div className="font-['Bebas_Neue'] text-base sm:text-xl tracking-[0.07em] truncate">
|
|
|
|
|
|
{match.team1.name}
|
2026-06-14 15:36:44 +02:00
|
|
|
|
</div>
|
2026-06-14 21:07:56 +02:00
|
|
|
|
</Link>
|
|
|
|
|
|
<Link href={matchHref} className="text-center flex-shrink-0 block">
|
2026-06-15 18:08:23 +02:00
|
|
|
|
<div className="font-['Bebas_Neue'] text-[48px] sm:text-[76px] text-green leading-none hover:opacity-80 transition-opacity">
|
2026-06-14 21:07:56 +02:00
|
|
|
|
{hasScore
|
|
|
|
|
|
? match.scoreP
|
|
|
|
|
|
? `${match.scoreP[0]}–${match.scoreP[1]}`
|
|
|
|
|
|
: match.scoreEt
|
|
|
|
|
|
? `${match.scoreEt[0]}–${match.scoreEt[1]}`
|
2026-06-14 20:10:55 +02:00
|
|
|
|
: `${ft![0]}–${ft![1]}`
|
2026-06-14 21:07:56 +02:00
|
|
|
|
: '?–?'}
|
2026-06-14 15:36:44 +02:00
|
|
|
|
</div>
|
2026-06-14 21:07:56 +02:00
|
|
|
|
{match.scoreP && (
|
2026-06-15 18:08:23 +02:00
|
|
|
|
<div className="text-[10px] text-green-muted mt-0.5">{ft![0]}–{ft![1]} a.e.t.</div>
|
2026-06-14 21:07:56 +02:00
|
|
|
|
)}
|
|
|
|
|
|
{match.scoreEt && !match.scoreP && (
|
2026-06-15 18:08:23 +02:00
|
|
|
|
<div className="text-[10px] text-green-muted mt-0.5">{ft![0]}–{ft![1]} (a.e.t.)</div>
|
2026-06-14 21:07:56 +02:00
|
|
|
|
)}
|
2026-06-15 18:08:23 +02:00
|
|
|
|
<div className="text-[9px] text-green-muted tracking-[0.12em] uppercase mt-1.5">{match.round}</div>
|
|
|
|
|
|
<div className="text-[10px] text-green-dark mt-0.5">{match.date ? formatDate(match.date) : ''}</div>
|
2026-06-14 21:07:56 +02:00
|
|
|
|
</Link>
|
|
|
|
|
|
<Link href={match.team2.slug ? `/teams/${match.team2.slug}` : matchHref}
|
2026-06-15 18:08:23 +02:00
|
|
|
|
className={`text-center block transition-colors hover:text-green ${winner === 'away' ? 'text-text' : 'text-green-sec'}`}>
|
2026-06-14 21:07:56 +02:00
|
|
|
|
<TeamFlag name={match.team2.name} iso2={match.team2.iso2} size="xl" className="mb-2" />
|
|
|
|
|
|
<div className="font-['Bebas_Neue'] text-base sm:text-xl tracking-[0.07em] truncate">
|
|
|
|
|
|
{match.team2.name}
|
2026-06-14 15:36:44 +02:00
|
|
|
|
</div>
|
2026-06-14 21:07:56 +02:00
|
|
|
|
</Link>
|
2026-06-14 15:36:44 +02:00
|
|
|
|
</div>
|
2026-06-14 21:07:56 +02:00
|
|
|
|
</div>
|
2026-06-14 15:36:44 +02:00
|
|
|
|
)
|
|
|
|
|
|
}
|