"use client"; import { GroupTable, Match, Team } from "@/lib/types"; 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"), ); } export default function Groups({ tables, teams, matches, }: { tables: GroupTable[]; teams: Team[]; matches: Match[] }) { return (
{tables.map((t) => { const live = liveMatchFor(t.group, matches); return (
Gruppe {t.group} {live ? "● LIVE" : `${t.rows.reduce((a, r) => a + r.played, 0)} Spiele`}
{t.rows.map((r) => { const team = teamById(teams, r.teamId); const cls = r.rank <= 2 ? `q${r.rank}` : r.rank === 3 ? "q3" : ""; return ( ); })}
Team SpSUN Tore±Pkt
{r.rank} {team?.name ?? r.teamId} {team?.code && {team.code}} {r.played} {r.won} {r.drawn} {r.lost} {r.goalsFor}:{r.goalsAgainst} {r.goalDiff > 0 ? `+${r.goalDiff}` : r.goalDiff} {r.points}
); })}
); }