'use client'; import { useState } from 'react'; import { useRouter } from 'next/navigation'; import { Trophy, Crown, Star, TrendingUp, Shield, Search, Users, Award, ChevronRight, Flag, Activity, BarChart3, } 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 { useDriverLeaderboard } from '@/hooks/useDriverService'; import Image from 'next/image'; import { mediaConfig } from '@/lib/config/mediaConfig'; import type { DriverLeaderboardItemViewModel } from '@/lib/view-models/DriverLeaderboardItemViewModel'; // ============================================================================ // DEMO DATA // ============================================================================ // // In alpha, all driver listings come from the in-memory repositories wired // through the DI container. We intentionally avoid hardcoded fallback driver // lists here so that the demo data stays consistent across pages. // ============================================================================ // SKILL LEVEL CONFIG // ============================================================================ const SKILL_LEVELS: { id: string; 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' }, ]; // ============================================================================ // CATEGORY CONFIG // ============================================================================ const CATEGORIES: { id: string; label: string; color: string; bgColor: string; borderColor: string; }[] = [ { id: 'beginner', label: 'Beginner', color: 'text-green-400', bgColor: 'bg-green-400/10', borderColor: 'border-green-400/30' }, { id: 'intermediate', label: 'Intermediate', color: 'text-primary-blue', bgColor: 'bg-primary-blue/10', borderColor: 'border-primary-blue/30' }, { id: 'advanced', label: 'Advanced', color: 'text-purple-400', bgColor: 'bg-purple-400/10', borderColor: 'border-purple-400/30' }, { id: 'pro', label: 'Pro', color: 'text-yellow-400', bgColor: 'bg-yellow-400/10', borderColor: 'border-yellow-400/30' }, { id: 'endurance', label: 'Endurance', color: 'text-orange-400', bgColor: 'bg-orange-400/10', borderColor: 'border-orange-400/30' }, { id: 'sprint', label: 'Sprint', color: 'text-red-400', bgColor: 'bg-red-400/10', borderColor: 'border-red-400/30' }, ]; // ============================================================================ // FEATURED DRIVER CARD COMPONENT // ============================================================================ interface FeaturedDriverCardProps { driver: DriverLeaderboardItemViewModel; position: number; onClick: () => void; } function FeaturedDriverCard({ driver, position, onClick }: FeaturedDriverCardProps) { const levelConfig = SKILL_LEVELS.find((l) => l.id === driver.skillLevel); const categoryConfig = CATEGORIES.find((c) => c.id === driver.category); 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: DriverLeaderboardItemViewModel[]; } 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
Driver population by category
{category.label}
{category.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}"