'use client';
import React from 'react';
import { Box } from '@/ui/Box';
import { Text } from '@/ui/Text';
import { Stack } from '@/ui/Stack';
import { Group } from '@/ui/Group';
import { Surface } from '@/ui/Surface';
import { Icon } from '@/ui/Icon';
import { Button } from '@/ui/Button';
import { Badge } from '@/ui/Badge';
import {
Calendar,
Clock,
Car,
MapPin,
Thermometer,
Droplets,
Wind,
Cloud,
X,
Trophy,
CheckCircle
} from 'lucide-react';
import { DateDisplay } from '@/lib/display-objects/DateDisplay';
interface RaceDetailModalProps {
race: {
id: string;
name: string;
track?: string;
car?: string;
sessionType?: string;
scheduledAt: string;
status: 'scheduled' | 'completed';
strengthOfField?: number;
isUserRegistered?: boolean;
canRegister?: boolean;
};
isOpen: boolean;
onClose: () => void;
onRegister?: () => void;
onWithdraw?: () => void;
onResultsClick?: () => void;
}
export function RaceDetailModal({
race,
isOpen,
onClose,
onRegister,
onWithdraw,
onResultsClick,
}: RaceDetailModalProps) {
if (!isOpen) return null;
const formatTime = (scheduledAt: string) => {
return DateDisplay.formatDateTime(scheduledAt);
};
const getStatusBadge = (status: 'scheduled' | 'completed') => {
if (status === 'completed') {
return Completed;
}
return Scheduled;
};
return (
e.stopPropagation()}
>
{/* Header */}
{race.name || `Race ${race.id.substring(0, 4)}`}
{getStatusBadge(race.status)}
}
>
Close
{/* Content */}
{/* Basic Info */}
Race Details
{race.track || 'TBA'}
{race.car || 'TBA'}
{formatTime(race.scheduledAt)}
{race.sessionType && (
{race.sessionType}
)}
{/* Weather Info (Mock Data) */}
Weather Conditions
Air: 24°C
Track: 31°C
Humidity: 45%
Wind: 12 km/h NW
Partly Cloudy
{/* Car Classes */}
Car Classes
GT3
GT4
TCR
{/* Strength of Field */}
{race.strengthOfField && (
Strength of Field
{race.strengthOfField.toFixed(1)} / 10.0
)}
{/* Action Buttons */}
{race.status === 'scheduled' && (
{!race.isUserRegistered && race.canRegister && onRegister && (
}
fullWidth
>
Register
)}
{race.isUserRegistered && onWithdraw && (
}
fullWidth
>
Withdraw
)}
)}
{race.status === 'completed' && onResultsClick && (
}
fullWidth
>
View Results
)}
);
}