'use client'; import Card from '../ui/Card'; import RankBadge from './RankBadge'; import { getDriverStats, getAllDriverRankings, getLeagueRankings } from '@/lib/di-container'; import { getPrimaryLeagueIdForDriver } from '@/lib/leagueMembership'; 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 primaryLeagueId = driverId ? getPrimaryLeagueIdForDriver(driverId) : null; const leagueRank = driverId && primaryLeagueId ? getLeagueRankings(driverId, primaryLeagueId) : 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, } : null); const winRate = defaultStats && defaultStats.totalRaces > 0 ? ((defaultStats.wins / defaultStats.totalRaces) * 100).toFixed(1) : '0.0'; const podiumRate = defaultStats && defaultStats.totalRaces > 0 ? ((defaultStats.podiums / defaultStats.totalRaces) * 100).toFixed(1) : '0.0'; 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 (
No statistics available yet. Compete in races to start building your record.
Detailed per-car and per-class performance breakdowns will be available in a future version once more race history data is tracked.
Performance trends, track-specific stats, head-to-head comparisons vs friends, and league member comparisons will be available in production.