'use client'; import CreateDriverForm from '@/components/drivers/CreateDriverForm'; import ProfileRaceHistory from '@/components/drivers/ProfileRaceHistory'; import ProfileSettings from '@/components/drivers/ProfileSettings'; import Button from '@/components/ui/Button'; import Card from '@/components/ui/Card'; import Heading from '@/components/ui/Heading'; import { useEffectiveDriverId } from '@/hooks/useEffectiveDriverId'; import { useServices } from '@/lib/services/ServiceProvider'; import type { DriverProfileAchievementViewModel, DriverProfileSocialHandleViewModel, DriverProfileViewModel } from '@/lib/view-models/DriverProfileViewModel'; import { getMediaUrl } from '@/lib/utilities/media'; import { Activity, Award, BarChart3, Calendar, ChevronRight, Clock, Crown, Edit3, ExternalLink, Flag, Globe, History, Medal, MessageCircle, Percent, Settings, Shield, Star, Target, TrendingUp, Trophy, Twitch, Twitter, User, UserPlus, Users, Youtube, Zap, } from 'lucide-react'; import Image from 'next/image'; import Link from 'next/link'; import { useRouter, useSearchParams } from 'next/navigation'; import { useEffect, useState } from 'react'; // ============================================================================ // TYPES // ============================================================================ type ProfileTab = 'overview' | 'history' | 'stats'; // ============================================================================ // HELPER COMPONENTS // ============================================================================ function getCountryFlag(countryCode: string): string { const code = countryCode.toUpperCase(); if (code.length === 2) { const codePoints = [...code].map(char => 127397 + char.charCodeAt(0)); return String.fromCodePoint(...codePoints); } return '🏁'; } function getRarityColor(rarity: DriverProfileAchievementViewModel['rarity']) { switch (rarity) { case 'common': return 'text-gray-400 bg-gray-400/10 border-gray-400/30'; case 'rare': return 'text-primary-blue bg-primary-blue/10 border-primary-blue/30'; case 'epic': return 'text-purple-400 bg-purple-400/10 border-purple-400/30'; case 'legendary': return 'text-yellow-400 bg-yellow-400/10 border-yellow-400/30'; } } function getAchievementIcon(icon: DriverProfileAchievementViewModel['icon']) { switch (icon) { case 'trophy': return Trophy; case 'medal': return Medal; case 'star': return Star; case 'crown': return Crown; case 'target': return Target; case 'zap': return Zap; } } function getSocialIcon(platform: DriverProfileSocialHandleViewModel['platform']) { switch (platform) { case 'twitter': return Twitter; case 'youtube': return Youtube; case 'twitch': return Twitch; case 'discord': return MessageCircle; } } function getSocialColor(platform: DriverProfileSocialHandleViewModel['platform']) { switch (platform) { case 'twitter': return 'hover:text-sky-400 hover:bg-sky-400/10'; case 'youtube': return 'hover:text-red-500 hover:bg-red-500/10'; case 'twitch': return 'hover:text-purple-400 hover:bg-purple-400/10'; case 'discord': return 'hover:text-indigo-400 hover:bg-indigo-400/10'; } } // ============================================================================ // STAT DIAGRAM COMPONENTS // ============================================================================ interface CircularProgressProps { value: number; max: number; label: string; color: string; size?: number; } function CircularProgress({ value, max, label, color, size = 80 }: CircularProgressProps) { const percentage = Math.min((value / max) * 100, 100); const strokeWidth = 6; const radius = (size - strokeWidth) / 2; const circumference = radius * 2 * Math.PI; const strokeDashoffset = circumference - (percentage / 100) * circumference; return (
Loading profile...
Join the GridPilot community and start your racing journey
Create your driver profile to join leagues, compete in races, and connect with other drivers.
{currentDriver.bio}
{membership.teamName}
P{stats.bestFinish}
P{(stats.avgFinish ?? 0).toFixed(1)}
No race statistics available yet. Join a league and compete to start building your record!
)}{extendedProfile.racingStyle}
{extendedProfile.favoriteTrack}
{extendedProfile.favoriteCar}
{extendedProfile.availableHours}
{achievement.title}
{achievement.description}
{new Date(achievement.earnedAt).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric', })}
{((stats.wins / stats.totalRaces) * 100).toFixed(1)}%
{((stats.podiums / stats.totalRaces) * 100).toFixed(1)}%
{stats.consistency ?? 0}%
{(((stats.totalRaces - stats.dnfs) / stats.totalRaces) * 100).toFixed(1)}%
No statistics available yet
Join a league and complete races to see detailed stats