'use client'; import Card from '../ui/Card'; import RankBadge from './RankBadge'; import { getDriverStats, getAllDriverRankings, getLeagueRankings } from '@/lib/di-container'; interface ProfileStatsProps { driverId?: string; stats?: { totalRaces: number; wins: number; podiums: number; dnfs: number; avgFinish: number; completionRate: number; }; } export default function ProfileStats({ driverId, stats }: ProfileStatsProps) { const driverStats = driverId ? getDriverStats(driverId) : null; const allRankings = getAllDriverRankings(); const leagueRank = driverId ? getLeagueRankings(driverId, 'league-1') : null; const defaultStats = stats || (driverStats ? { totalRaces: driverStats.totalRaces, wins: driverStats.wins, podiums: driverStats.podiums, dnfs: driverStats.dnfs, avgFinish: driverStats.avgFinish, completionRate: ((driverStats.totalRaces - driverStats.dnfs) / driverStats.totalRaces) * 100 } : { totalRaces: 147, wins: 23, podiums: 56, dnfs: 12, avgFinish: 5.8, completionRate: 91.8 }); const winRate = ((defaultStats.wins / defaultStats.totalRaces) * 100).toFixed(1); const podiumRate = ((defaultStats.podiums / defaultStats.totalRaces) * 100).toFixed(1); const getTrendIndicator = (value: number) => { if (value > 0) return '↑'; if (value < 0) return '↓'; return '→'; }; const getPercentileLabel = (percentile: number) => { if (percentile >= 90) return 'Top 10%'; if (percentile >= 75) return 'Top 25%'; if (percentile >= 50) return 'Top 50%'; return `${(100 - percentile).toFixed(0)}th percentile`; }; const getPercentileColor = (percentile: number) => { if (percentile >= 90) return 'text-green-400'; if (percentile >= 75) return 'text-primary-blue'; if (percentile >= 50) return 'text-warning-amber'; return 'text-gray-400'; }; return (
{driverStats && (

Rankings Dashboard

Overall Ranking
{driverStats.overallRank} of {allRankings.length} drivers
{getPercentileLabel(driverStats.percentile)}
Global Percentile
{driverStats.rating}
Rating
{getTrendIndicator(5)} {winRate}%
Win Rate
{getTrendIndicator(2)} {podiumRate}%
Podium Rate
{leagueRank && leagueRank.totalDrivers > 0 && (
European GT Championship
{leagueRank.rank} of {leagueRank.totalDrivers} drivers
{getPercentileLabel(leagueRank.percentile)}
League Percentile
)}
)}
{[ { label: 'Total Races', value: defaultStats.totalRaces, color: 'text-primary-blue' }, { label: 'Wins', value: defaultStats.wins, color: 'text-green-400' }, { label: 'Podiums', value: defaultStats.podiums, color: 'text-warning-amber' }, { label: 'DNFs', value: defaultStats.dnfs, color: 'text-red-400' }, { label: 'Avg Finish', value: defaultStats.avgFinish.toFixed(1), color: 'text-white' }, { label: 'Completion', value: `${defaultStats.completionRate.toFixed(1)}%`, color: 'text-green-400' }, { label: 'Win Rate', value: `${winRate}%`, color: 'text-primary-blue' }, { label: 'Podium Rate', value: `${podiumRate}%`, color: 'text-warning-amber' } ].map((stat, index) => (
{stat.label}
{stat.value}
))}

Performance by Car Class

📊

Coming Soon

Performance trends, track-specific stats, head-to-head comparisons vs friends, and league member comparisons will be available in production.

); } function PerformanceRow({ label, races, wins, podiums, avgFinish }: { label: string; races: number; wins: number; podiums: number; avgFinish: number; }) { const winRate = ((wins / races) * 100).toFixed(0); return (
{label}
{races} races
Wins
{wins} ({winRate}%)
Podiums
{podiums}
Avg
{avgFinish.toFixed(1)}
); }