"use client"; import { GroupId, GroupTable, Match, Team } from "@/lib/types"; import Flag from "./Flag"; function teamById(teams: Team[], id: string) { return teams.find((t) => t.id === id); } function liveMatchFor(group: string, matches: Match[]) { return matches.find( (m) => m.group === group && (m.status === "LIVE" || m.status === "IN_PLAY" || m.status === "PAUSED"), ); } function liveTeamIdsFor(group: GroupId, matches: Match[]): Set { const ids = new Set(); for (const m of matches) { if (m.group !== group) continue; if (m.status === "LIVE" || m.status === "IN_PLAY" || m.status === "PAUSED") { if (m.homeTeamId) ids.add(m.homeTeamId); if (m.awayTeamId) ids.add(m.awayTeamId); } } return ids; } export default function Groups({ tables, teams, matches, onOpenGroup, }: { tables: GroupTable[]; teams: Team[]; matches: Match[]; onOpenGroup: (g: GroupId) => void; }) { return (
{tables.map((t) => { const live = liveMatchFor(t.group, matches); const liveIds = liveTeamIdsFor(t.group, matches); return (
{t.rows.map((r) => { const team = teamById(teams, r.teamId); const cls = r.rank <= 2 ? `q${r.rank}` : r.rank === 3 ? "q3" : ""; const isLive = liveIds.has(r.teamId); return ( ); })}
Mannschaft SpSUN Tore±Pkt
{r.rank} {team?.localisedName ?? team?.name ?? r.teamId} {isLive && } {r.played} {r.won} {r.drawn} {r.lost} {r.goalsFor}:{r.goalsAgainst} {r.goalDiff > 0 ? `+${r.goalDiff}` : r.goalDiff} {r.points}
); })}
); }