'use client'; import React, { useState } from 'react'; import { useRouter } from 'next/navigation'; import { getQuickPenaltyUseCase } from '@/lib/di-container'; import type { Driver } from '@gridpilot/racing/application'; import Button from '@/components/ui/Button'; import { AlertTriangle, Clock, Flag, Zap } from 'lucide-react'; interface QuickPenaltyModalProps { raceId: string; drivers: Driver[]; onClose: () => void; } const INFRACTION_TYPES = [ { value: 'track_limits', label: 'Track Limits', icon: Flag }, { value: 'unsafe_rejoin', label: 'Unsafe Rejoin', icon: AlertTriangle }, { value: 'aggressive_driving', label: 'Aggressive Driving', icon: Zap }, { value: 'false_start', label: 'False Start', icon: Clock }, { value: 'other', label: 'Other', icon: AlertTriangle }, ] as const; const SEVERITY_LEVELS = [ { value: 'warning', label: 'Warning', description: 'Official warning only' }, { value: 'minor', label: 'Minor', description: 'Light penalty' }, { value: 'major', label: 'Major', description: 'Significant penalty' }, { value: 'severe', label: 'Severe', description: 'Heavy penalty' }, ] as const; export default function QuickPenaltyModal({ raceId, drivers, onClose }: QuickPenaltyModalProps) { const [selectedDriver, setSelectedDriver] = useState(''); const [infractionType, setInfractionType] = useState(''); const [severity, setSeverity] = useState(''); const [notes, setNotes] = useState(''); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const router = useRouter(); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (!selectedDriver || !infractionType || !severity) return; setLoading(true); setError(null); try { const useCase = getQuickPenaltyUseCase(); await useCase.execute({ raceId, driverId: selectedDriver, adminId: 'driver-1', // TODO: Get from current user context infractionType: infractionType as any, severity: severity as any, notes: notes.trim() || undefined, }); // Refresh the page to show updated results router.refresh(); onClose(); } catch (err) { setError(err instanceof Error ? err.message : 'Failed to apply penalty'); } finally { setLoading(false); } }; return (

Quick Penalty

{/* Driver Selection */}
{/* Infraction Type */}
{INFRACTION_TYPES.map(({ value, label, icon: Icon }) => ( ))}
{/* Severity */}
{SEVERITY_LEVELS.map(({ value, label, description }) => ( ))}
{/* Notes */}