'use client'; import React from 'react'; import { Trophy, ArrowLeft, Medal } from 'lucide-react'; import Button from '@/components/ui/Button'; import Heading from '@/components/ui/Heading'; import Image from 'next/image'; import type { DriverRankingsViewData } from '@/lib/view-data/DriverRankingsViewData'; // ============================================================================ // TYPES // ============================================================================ interface DriverRankingsTemplateProps { viewData: DriverRankingsViewData; onDriverClick?: (id: string) => void; onBackToLeaderboards?: () => void; } // ============================================================================ // MAIN TEMPLATE COMPONENT // ============================================================================ export function DriverRankingsTemplate({ viewData, onDriverClick, onBackToLeaderboards, }: DriverRankingsTemplateProps): React.ReactElement { return (
{/* Header */}
{onBackToLeaderboards && ( )}
Driver Leaderboard

Full rankings of all drivers by performance metrics

{/* Top 3 Podium */} {viewData.podium.length > 0 && (
{[1, 0, 2].map((index) => { const driver = viewData.podium[index]; if (!driver) return null; const position = index === 1 ? 1 : index === 0 ? 2 : 3; const config = { 1: { height: 'h-40', color: 'from-yellow-400/20 to-amber-500/10 border-yellow-400/40', crown: 'text-yellow-400', text: 'text-xl text-yellow-400' }, 2: { height: 'h-32', color: 'from-gray-400/20 to-gray-500/10 border-gray-400/40', crown: 'text-gray-300', text: 'text-lg text-gray-300' }, 3: { height: 'h-24', color: 'from-amber-600/20 to-amber-700/10 border-amber-600/40', crown: 'text-amber-600', text: 'text-base text-amber-600' }, }[position]; return ( ); })}
)} {/* Leaderboard Table */}
{/* Table Header */}
Rank
Driver
Races
Rating
Wins
Podiums
Win Rate
{/* Table Body */}
{viewData.drivers.map((driver) => { const position = driver.rank; const medalBg = position === 1 ? 'bg-gradient-to-br from-yellow-400/20 to-yellow-600/10 border-yellow-400/40' : position === 2 ? 'bg-gradient-to-br from-gray-300/20 to-gray-400/10 border-gray-300/40' : position === 3 ? 'bg-gradient-to-br from-amber-600/20 to-amber-700/10 border-amber-600/40' : 'bg-iron-gray/50 border-charcoal-outline'; const medalColor = position === 1 ? 'text-yellow-400' : position === 2 ? 'text-gray-300' : position === 3 ? 'text-amber-600' : 'text-gray-500'; return ( ); })}
{/* Empty State */} {viewData.drivers.length === 0 && (
🔍

No drivers found

There are no drivers in the system yet

)}
); }