This commit is contained in:
2025-12-04 23:31:55 +01:00
parent 9fa21a488a
commit fb509607c1
96 changed files with 5839 additions and 1609 deletions

View File

@@ -20,25 +20,28 @@ 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 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 '↑';
@@ -131,41 +134,74 @@ export default function ProfileStats({ driverId, stats }: ProfileStatsProps) {
</Card>
)}
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
{[
{ 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) => (
<Card key={index} className="text-center">
<div className="text-sm text-gray-400 mb-1">{stat.label}</div>
<div className={`text-2xl font-bold ${stat.color}`}>{stat.value}</div>
</Card>
))}
</div>
<Card>
<h3 className="text-lg font-semibold text-white mb-4">Performance by Car Class</h3>
<div className="space-y-3 text-sm">
<PerformanceRow label="GT3" races={45} wins={12} podiums={23} avgFinish={4.2} />
<PerformanceRow label="Formula" races={38} wins={7} podiums={15} avgFinish={6.1} />
<PerformanceRow label="LMP2" races={32} wins={4} podiums={11} avgFinish={7.3} />
<PerformanceRow label="Other" races={32} wins={0} podiums={7} avgFinish={8.5} />
</div>
</Card>
{defaultStats ? (
<>
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
{[
{
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) => (
<Card key={index} className="text-center">
<div className="text-sm text-gray-400 mb-1">{stat.label}</div>
<div className={`text-2xl font-bold ${stat.color}`}>{stat.value}</div>
</Card>
))}
</div>
</>
) : (
<Card>
<h3 className="text-lg font-semibold text-white mb-2">Career Statistics</h3>
<p className="text-sm text-gray-400">
No statistics available yet. Compete in races to start building your record.
</p>
</Card>
)}
<Card className="bg-charcoal-200/50 border-primary-blue/30">
<div className="flex items-center gap-3 mb-3">
<div className="text-2xl">📊</div>
<h3 className="text-lg font-semibold text-white">Performance by Car Class</h3>
</div>
<p className="text-gray-400 text-sm">
Detailed per-car and per-class performance breakdowns will be available in a future
version once more race history data is tracked.
</p>
</Card>
<Card className="bg-charcoal-200/50 border-primary-blue/30">
<div className="flex items-center gap-3 mb-3">
<div className="text-2xl">📈</div>
<h3 className="text-lg font-semibold text-white">Coming Soon</h3>
</div>
<p className="text-gray-400 text-sm">
Performance trends, track-specific stats, head-to-head comparisons vs friends, and league member comparisons will be available in production.
Performance trends, track-specific stats, head-to-head comparisons vs friends, and
league member comparisons will be available in production.
</p>
</Card>
</div>