90 lines
2.8 KiB
TypeScript
90 lines
2.8 KiB
TypeScript
'use client';
|
|
|
|
import { useState, useEffect } from 'react';
|
|
import Card from '@/components/ui/Card';
|
|
import { useServices } from '@/lib/services/ServiceProvider';
|
|
|
|
interface TeamStandingsProps {
|
|
teamId: string;
|
|
leagues: string[];
|
|
}
|
|
|
|
export default function TeamStandings({ teamId, leagues }: TeamStandingsProps) {
|
|
const { leagueService } = useServices();
|
|
const [standings, setStandings] = useState<any[]>([]);
|
|
const [loading, setLoading] = useState(true);
|
|
|
|
useEffect(() => {
|
|
const load = async () => {
|
|
try {
|
|
// For demo purposes, create mock standings
|
|
const mockStandings = leagues.map(leagueId => ({
|
|
leagueId,
|
|
leagueName: `League ${leagueId}`,
|
|
position: Math.floor(Math.random() * 10) + 1,
|
|
points: Math.floor(Math.random() * 100),
|
|
wins: Math.floor(Math.random() * 5),
|
|
racesCompleted: Math.floor(Math.random() * 10),
|
|
}));
|
|
setStandings(mockStandings);
|
|
} catch (error) {
|
|
console.error('Failed to load standings:', error);
|
|
} 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>
|
|
);
|
|
} |