import { useState } from 'react'; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; import { useTournament } from '@/context/TournamentContext'; import { Trophy, Star, BarChart3, TrendingUp, TrendingDown, Minus } from 'lucide-react'; import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, Legend } from 'recharts'; const CHART_COLORS = [ 'hsl(211, 100%, 50%)', 'hsl(0, 72%, 51%)', 'hsl(142, 71%, 45%)', 'hsl(45, 93%, 47%)', 'hsl(280, 65%, 60%)', 'hsl(180, 65%, 45%)', 'hsl(320, 65%, 52%)', 'hsl(30, 80%, 55%)', ]; export const ScoreboardModal = () => { const { getTeamScores, rounds } = useTournament(); const [open, setOpen] = useState(false); const bundesligaScores = getTeamScores('bundesliga'); const championsScores = getTeamScores('champions'); const createChartData = (league: 'bundesliga' | 'champions') => { const scores = league === 'bundesliga' ? bundesligaScores : championsScores; if (rounds.length === 0) return []; const data = []; // Add starting point const startPoint: Record = { round: 'Start' }; scores.forEach((s) => { startPoint[s.team.name] = 0; }); data.push(startPoint); // Add each round for (let i = 0; i < rounds.length; i++) { const point: Record = { round: `Runde ${i + 1}` }; scores.forEach((s) => { const cumulativePoints = s.pointsHistory.slice(0, i + 1).reduce((a, b) => a + b, 0); point[s.team.name] = cumulativePoints; }); data.push(point); } return data; }; const renderScoreTable = (league: 'bundesliga' | 'champions') => { const scores = league === 'bundesliga' ? bundesligaScores : championsScores; const Icon = league === 'bundesliga' ? Trophy : Star; const badgeClass = league === 'bundesliga' ? 'bg-bundesliga/10 text-bundesliga' : 'bg-champions/20 text-champions-foreground'; if (scores.length === 0) { return (
Keine Teams in dieser Liga
); } return (
{scores.map((score, index) => { const lastRoundPoints = score.pointsHistory[score.pointsHistory.length - 1] ?? 0; return ( ); })}
# Team Spiele Punkte Trend
{index + 1}

{score.team.name}

{score.team.club}

{score.matchesPlayed} 0 ? 'text-field' : score.totalPoints < 0 ? 'text-destructive' : 'text-foreground' }`}> {score.totalPoints > 0 ? '+' : ''}{score.totalPoints}
{lastRoundPoints > 0 ? ( ) : lastRoundPoints < 0 ? ( ) : ( )}
{rounds.length > 0 && (

Punkteverlauf

{scores.map((score, index) => ( ))}
)}
); }; return ( Scoreboard Bundesliga Champions League {renderScoreTable('bundesliga')} {renderScoreTable('champions')} ); };