'use client'; import { useEffect, useState } from 'react'; import { useRouter } from 'next/navigation'; import { Trophy, Medal, Crown, Star, TrendingUp, Shield, Search, Plus, Sparkles, Users, Target, Zap, Award, ChevronRight, Flame, Flag, Activity, BarChart3, UserPlus, } from 'lucide-react'; import Button from '@/components/ui/Button'; import Input from '@/components/ui/Input'; import Card from '@/components/ui/Card'; import Heading from '@/components/ui/Heading'; import { getDriverRepository, getDriverStats, getAllDriverRankings, getImageService } from '@/lib/di-container'; import Image from 'next/image'; // ============================================================================ // TYPES // ============================================================================ type SkillLevel = 'beginner' | 'intermediate' | 'advanced' | 'pro'; interface DriverListItem { id: string; name: string; rating: number; skillLevel: SkillLevel; nationality: string; racesCompleted: number; wins: number; podiums: number; isActive: boolean; rank: number; } // ============================================================================ // DEMO DATA // ============================================================================ const DEMO_DRIVERS: DriverListItem[] = [ { id: 'demo-1', name: 'Max Verstappen', rating: 4250, skillLevel: 'pro', nationality: 'NL', racesCompleted: 156, wins: 47, podiums: 89, isActive: true, rank: 1 }, { id: 'demo-2', name: 'Lewis Hamilton', rating: 4180, skillLevel: 'pro', nationality: 'GB', racesCompleted: 198, wins: 52, podiums: 112, isActive: true, rank: 2 }, { id: 'demo-3', name: 'Charles Leclerc', rating: 3950, skillLevel: 'pro', nationality: 'MC', racesCompleted: 134, wins: 28, podiums: 67, isActive: true, rank: 3 }, { id: 'demo-4', name: 'Lando Norris', rating: 3820, skillLevel: 'advanced', nationality: 'GB', racesCompleted: 112, wins: 18, podiums: 45, isActive: true, rank: 4 }, { id: 'demo-5', name: 'Carlos Sainz', rating: 3750, skillLevel: 'advanced', nationality: 'ES', racesCompleted: 145, wins: 15, podiums: 52, isActive: true, rank: 5 }, { id: 'demo-6', name: 'Oscar Piastri', rating: 3680, skillLevel: 'advanced', nationality: 'AU', racesCompleted: 78, wins: 8, podiums: 24, isActive: true, rank: 6 }, { id: 'demo-7', name: 'George Russell', rating: 3620, skillLevel: 'advanced', nationality: 'GB', racesCompleted: 98, wins: 6, podiums: 31, isActive: true, rank: 7 }, { id: 'demo-8', name: 'Fernando Alonso', rating: 3580, skillLevel: 'advanced', nationality: 'ES', racesCompleted: 256, wins: 32, podiums: 98, isActive: true, rank: 8 }, { id: 'demo-9', name: 'Nico Hülkenberg', rating: 3420, skillLevel: 'advanced', nationality: 'DE', racesCompleted: 167, wins: 2, podiums: 18, isActive: true, rank: 9 }, { id: 'demo-10', name: 'Yuki Tsunoda', rating: 3250, skillLevel: 'intermediate', nationality: 'JP', racesCompleted: 89, wins: 1, podiums: 8, isActive: true, rank: 10 }, { id: 'demo-11', name: 'Alex Albon', rating: 3180, skillLevel: 'intermediate', nationality: 'TH', racesCompleted: 102, wins: 0, podiums: 4, isActive: true, rank: 11 }, { id: 'demo-12', name: 'Kevin Magnussen', rating: 3050, skillLevel: 'intermediate', nationality: 'DK', racesCompleted: 145, wins: 0, podiums: 2, isActive: true, rank: 12 }, { id: 'demo-13', name: 'Pierre Gasly', rating: 2980, skillLevel: 'intermediate', nationality: 'FR', racesCompleted: 124, wins: 1, podiums: 5, isActive: true, rank: 13 }, { id: 'demo-14', name: 'Esteban Ocon', rating: 2920, skillLevel: 'intermediate', nationality: 'FR', racesCompleted: 118, wins: 1, podiums: 4, isActive: true, rank: 14 }, { id: 'demo-15', name: 'Lance Stroll', rating: 2850, skillLevel: 'intermediate', nationality: 'CA', racesCompleted: 134, wins: 0, podiums: 3, isActive: true, rank: 15 }, { id: 'demo-16', name: 'Zhou Guanyu', rating: 2650, skillLevel: 'intermediate', nationality: 'CN', racesCompleted: 67, wins: 0, podiums: 0, isActive: true, rank: 16 }, { id: 'demo-17', name: 'Daniel Ricciardo', rating: 2500, skillLevel: 'intermediate', nationality: 'AU', racesCompleted: 189, wins: 8, podiums: 32, isActive: false, rank: 17 }, { id: 'demo-18', name: 'Valtteri Bottas', rating: 2450, skillLevel: 'intermediate', nationality: 'FI', racesCompleted: 212, wins: 10, podiums: 67, isActive: false, rank: 18 }, { id: 'demo-19', name: 'Logan Sargeant', rating: 1850, skillLevel: 'beginner', nationality: 'US', racesCompleted: 34, wins: 0, podiums: 0, isActive: false, rank: 19 }, { id: 'demo-20', name: 'Nyck de Vries', rating: 1750, skillLevel: 'beginner', nationality: 'NL', racesCompleted: 12, wins: 0, podiums: 0, isActive: false, rank: 20 }, ]; // ============================================================================ // SKILL LEVEL CONFIG // ============================================================================ const SKILL_LEVELS: { id: SkillLevel; label: string; icon: React.ElementType; color: string; bgColor: string; borderColor: string; description: string; }[] = [ { id: 'pro', label: 'Pro', icon: Crown, color: 'text-yellow-400', bgColor: 'bg-yellow-400/10', borderColor: 'border-yellow-400/30', description: 'Elite competition level' }, { id: 'advanced', label: 'Advanced', icon: Star, color: 'text-purple-400', bgColor: 'bg-purple-400/10', borderColor: 'border-purple-400/30', description: 'Highly competitive' }, { id: 'intermediate', label: 'Intermediate', icon: TrendingUp, color: 'text-primary-blue', bgColor: 'bg-primary-blue/10', borderColor: 'border-primary-blue/30', description: 'Developing skills' }, { id: 'beginner', label: 'Beginner', icon: Shield, color: 'text-green-400', bgColor: 'bg-green-400/10', borderColor: 'border-green-400/30', description: 'Learning the ropes' }, ]; // ============================================================================ // FEATURED DRIVER CARD COMPONENT // ============================================================================ interface FeaturedDriverCardProps { driver: DriverListItem; position: number; onClick: () => void; } function FeaturedDriverCard({ driver, position, onClick }: FeaturedDriverCardProps) { const imageService = getImageService(); const levelConfig = SKILL_LEVELS.find((l) => l.id === driver.skillLevel); const getBorderColor = (pos: number) => { switch (pos) { case 1: return 'border-yellow-400/50 hover:border-yellow-400'; case 2: return 'border-gray-300/50 hover:border-gray-300'; case 3: return 'border-amber-600/50 hover:border-amber-600'; default: return 'border-charcoal-outline hover:border-primary-blue'; } }; const getMedalColor = (pos: number) => { switch (pos) { case 1: return 'text-yellow-400'; case 2: return 'text-gray-300'; case 3: return 'text-amber-600'; default: return 'text-gray-500'; } }; return ( ); } // ============================================================================ // SKILL DISTRIBUTION COMPONENT // ============================================================================ interface SkillDistributionProps { drivers: DriverListItem[]; } function SkillDistribution({ drivers }: SkillDistributionProps) { const distribution = SKILL_LEVELS.map((level) => ({ ...level, count: drivers.filter((d) => d.skillLevel === level.id).length, percentage: drivers.length > 0 ? Math.round((drivers.filter((d) => d.skillLevel === level.id).length / drivers.length) * 100) : 0, })); return (
Driver population by skill level
{level.label}
{level.percentage}% of drivers
Highest rated competitors
Currently competing in leagues
Loading drivers...
Meet the racers who make every lap count. From rookies to champions, track their journey and see who's dominating the grid.
{/* Quick Stats */}See full driver rankings
Top performers on the grid
No drivers found matching "{searchQuery}"