82 lines
2.5 KiB
TypeScript
82 lines
2.5 KiB
TypeScript
'use client';
|
|
|
|
import { useState, useEffect } from 'react';
|
|
import Card from '@/components/ui/Card';
|
|
import {
|
|
loadTeamStandings,
|
|
type TeamLeagueStandingViewModel,
|
|
} from '@/lib/presenters/TeamStandingsPresenter';
|
|
|
|
interface TeamStandingsProps {
|
|
teamId: string;
|
|
leagues: string[];
|
|
}
|
|
|
|
export default function TeamStandings({ teamId, leagues }: TeamStandingsProps) {
|
|
const [standings, setStandings] = useState<TeamLeagueStandingViewModel[]>([]);
|
|
const [loading, setLoading] = useState(true);
|
|
|
|
useEffect(() => {
|
|
const load = async () => {
|
|
try {
|
|
const viewModel = await loadTeamStandings(teamId, leagues);
|
|
setStandings(viewModel.standings);
|
|
} finally {
|
|
setLoading(false);
|
|
}
|
|
};
|
|
|
|
void load();
|
|
}, [teamId, leagues]);
|
|
|
|
if (loading) {
|
|
return (
|
|
<Card>
|
|
<div className="text-center py-8 text-gray-400">Loading standings...</div>
|
|
</Card>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<Card>
|
|
<h3 className="text-xl font-semibold text-white mb-6">League Standings</h3>
|
|
|
|
<div className="space-y-4">
|
|
{standings.map((standing) => (
|
|
<div
|
|
key={standing.leagueId}
|
|
className="p-4 rounded-lg bg-deep-graphite border border-charcoal-outline"
|
|
>
|
|
<div className="flex items-center justify-between mb-3">
|
|
<h4 className="text-white font-medium">{standing.leagueName}</h4>
|
|
<span className="px-3 py-1 bg-primary-blue/20 text-primary-blue rounded-full text-sm font-semibold">
|
|
P{standing.position}
|
|
</span>
|
|
</div>
|
|
|
|
<div className="grid grid-cols-3 gap-4 text-center">
|
|
<div>
|
|
<div className="text-2xl font-bold text-white">{standing.points}</div>
|
|
<div className="text-xs text-gray-400">Points</div>
|
|
</div>
|
|
<div>
|
|
<div className="text-2xl font-bold text-white">{standing.wins}</div>
|
|
<div className="text-xs text-gray-400">Wins</div>
|
|
</div>
|
|
<div>
|
|
<div className="text-2xl font-bold text-white">{standing.racesCompleted}</div>
|
|
<div className="text-xs text-gray-400">Races</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
))}
|
|
</div>
|
|
|
|
{standings.length === 0 && (
|
|
<div className="text-center py-8 text-gray-400">
|
|
No standings available yet.
|
|
</div>
|
|
)}
|
|
</Card>
|
|
);
|
|
} |