'use client'; import type { DriverDTO } from '@gridpilot/racing/application/dto/DriverDTO'; import Card from '../ui/Card'; import ProfileHeader from '../profile/ProfileHeader'; import ProfileStats from './ProfileStats'; import CareerHighlights from './CareerHighlights'; import DriverRankings from './DriverRankings'; import PerformanceMetrics from './PerformanceMetrics'; import { useEffect, useState } from 'react'; import { getDriverStats, getLeagueRankings, getGetDriverTeamQuery, getAllDriverRankings } from '@/lib/di-container'; import type { GetDriverTeamQueryResultDTO } from '@gridpilot/racing/application/dto/TeamCommandAndQueryDTO'; interface DriverProfileProps { driver: DriverDTO; isOwnProfile?: boolean; onEditClick?: () => void; } export default function DriverProfile({ driver, isOwnProfile = false, onEditClick }: DriverProfileProps) { const driverStats = getDriverStats(driver.id); const leagueRank = getLeagueRankings(driver.id, 'league-1'); const allRankings = getAllDriverRankings(); const [teamData, setTeamData] = useState(null); useEffect(() => { const load = async () => { const query = getGetDriverTeamQuery(); const result = await query.execute({ driverId: driver.id }); setTeamData(result); }; void load(); }, [driver.id]); const performanceStats = driverStats ? { winRate: (driverStats.wins / driverStats.totalRaces) * 100, podiumRate: (driverStats.podiums / driverStats.totalRaces) * 100, dnfRate: (driverStats.dnfs / driverStats.totalRaces) * 100, avgFinish: driverStats.avgFinish, consistency: driverStats.consistency, bestFinish: driverStats.bestFinish, worstFinish: driverStats.worstFinish, } : null; const rankings = driverStats ? [ { type: 'overall' as const, name: 'Overall Ranking', rank: driverStats.overallRank, totalDrivers: allRankings.length, percentile: driverStats.percentile, rating: driverStats.rating, }, { type: 'league' as const, name: 'European GT Championship', rank: leagueRank.rank, totalDrivers: leagueRank.totalDrivers, percentile: leagueRank.percentile, rating: driverStats.rating, }, ] : []; return (
{driver.bio && (

About

{driver.bio}

)} {driverStats && (

Career Statistics

{performanceStats && }
)} {!driverStats && (

Career Statistics

No statistics available yet. Compete in races to start building your record.

)}

Performance by Class

🔒

Private Information

Detailed race history, settings, and preferences are only visible to the driver.

📊

Coming Soon

Per-car statistics, per-track performance, and head-to-head comparisons will be available in production.

); } function StatCard({ label, value, color }: { label: string; value: string; color: string }) { return (
{label}
{value}
); }