'use client'; import { Race } from '@core/racing/domain/entities/Race'; import { Clock, PlayCircle, CheckCircle2, XCircle, Zap, Car, Trophy } from 'lucide-react'; interface RaceCardProps { race: Race; leagueName?: string; onClick?: () => void; compact?: boolean; } export default function RaceCard({ race, leagueName, onClick, compact = false }: RaceCardProps) { const statusConfig = { scheduled: { icon: Clock, color: 'text-primary-blue', bg: 'bg-primary-blue/10', border: 'border-primary-blue/30', label: 'Scheduled', }, running: { icon: PlayCircle, color: 'text-performance-green', bg: 'bg-performance-green/10', border: 'border-performance-green/30', label: 'LIVE', }, completed: { icon: CheckCircle2, color: 'text-gray-400', bg: 'bg-gray-500/10', border: 'border-gray-500/30', label: 'Completed', }, cancelled: { icon: XCircle, color: 'text-warning-amber', bg: 'bg-warning-amber/10', border: 'border-warning-amber/30', label: 'Cancelled', }, }; const config = statusConfig[race.status]; const StatusIcon = config.icon; const formatDate = (date: Date) => { return new Date(date).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric', }); }; const formatTime = (date: Date) => { return new Date(date).toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', timeZoneName: 'short', }); }; const getRelativeTime = (date: Date) => { const now = new Date(); const targetDate = new Date(date); const diffMs = targetDate.getTime() - now.getTime(); const diffHours = Math.floor(diffMs / (1000 * 60 * 60)); const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24)); if (diffMs < 0) return null; if (diffHours < 1) return 'Starting soon'; if (diffHours < 24) return `In ${diffHours}h`; if (diffDays === 1) return 'Tomorrow'; if (diffDays < 7) return `In ${diffDays} days`; return null; }; const relativeTime = race.status === 'scheduled' ? getRelativeTime(race.scheduledAt) : null; if (compact) { return (
{formatTime(race.scheduledAt)}
{formatDate(race.scheduledAt)}
{formatTime(race.scheduledAt)}
{relativeTime && ({relativeTime}
)}