'use client'; import { FileText, Users, Calendar, Trophy, Award, Info } from 'lucide-react'; import Card from '@/components/ui/Card'; import type { LeagueConfigFormModel } from '@gridpilot/racing/application'; import type { LeagueScoringPresetDTO } from '@gridpilot/racing/application/ports/LeagueScoringPresetProvider'; interface LeagueReviewSummaryProps { form: LeagueConfigFormModel; presets: LeagueScoringPresetDTO[]; } export default function LeagueReviewSummary({ form, presets }: LeagueReviewSummaryProps) { const { basics, structure, timings, scoring, championships, dropPolicy } = form; const modeLabel = structure.mode === 'solo' ? 'Drivers only (solo)' : 'Teams with fixed drivers per team'; const capacitySentence = (() => { if (structure.mode === 'solo') { if (typeof structure.maxDrivers === 'number') { return `Up to ${structure.maxDrivers} drivers`; } return 'Capacity not fully specified'; } const parts: string[] = []; if (typeof structure.maxTeams === 'number') { parts.push(`Teams: ${structure.maxTeams}`); } if (typeof structure.driversPerTeam === 'number') { parts.push(`Drivers per team: ${structure.driversPerTeam}`); } if (typeof structure.maxDrivers === 'number') { parts.push(`Max grid: ${structure.maxDrivers}`); } if (parts.length === 0) { return '—'; } return parts.join(', '); })(); const formatMinutes = (value: number | undefined) => { if (typeof value !== 'number' || value <= 0) return '—'; return `${value} min`; }; const dropRuleSentence = (() => { if (dropPolicy.strategy === 'none') { return 'All results will count towards the championship.'; } if (dropPolicy.strategy === 'bestNResults') { if (typeof dropPolicy.n === 'number' && dropPolicy.n > 0) { return `Best ${dropPolicy.n} results will count; others are ignored.`; } return 'Best N results will count; others are ignored.'; } if (dropPolicy.strategy === 'dropWorstN') { if (typeof dropPolicy.n === 'number' && dropPolicy.n > 0) { return `Worst ${dropPolicy.n} results will be dropped from the standings.`; } return 'Worst N results will be dropped from the standings.'; } return 'All results will count towards the championship.'; })(); const preset = presets.find((p) => p.id === scoring.patternId) ?? null; const scoringPresetName = preset ? preset.name : scoring.patternId ? 'Preset not found' : '—'; const scoringPatternSummary = preset?.sessionSummary ?? '—'; const dropPolicySummary = dropRuleSentence; const enabledChampionshipsLabels: string[] = []; if (championships.enableDriverChampionship) enabledChampionshipsLabels.push('Driver'); if (championships.enableTeamChampionship) enabledChampionshipsLabels.push('Team'); if (championships.enableNationsChampionship) enabledChampionshipsLabels.push('Nations Cup'); if (championships.enableTrophyChampionship) enabledChampionshipsLabels.push('Trophy'); const championshipsSummary = enabledChampionshipsLabels.length === 0 ? 'None enabled yet.' : enabledChampionshipsLabels.join(', '); const visibilityLabel = basics.visibility === 'public' ? 'Public' : 'Private'; const gameLabel = 'iRacing'; return (

Review your league configuration

Double-check all settings before creating your league. You can modify most of these later.

{/* 1. Basics & visibility */}

Basics & visibility

Name
{basics.name || '—'}
Visibility
{visibilityLabel}
Game
{gameLabel}
{basics.description && (
Description
{basics.description}
)}
{/* 2. Structure & capacity */}

Structure & capacity

Mode
{modeLabel}
Capacity
{capacitySentence}
{/* 3. Schedule & timings */}

Schedule & timings

Planned rounds
{typeof timings.roundsPlanned === 'number' ? timings.roundsPlanned : '—'}
Sessions per weekend
{timings.sessionCount ?? '—'}
Practice
{formatMinutes(timings.practiceMinutes)}
Qualifying
{formatMinutes(timings.qualifyingMinutes)}
Sprint
{formatMinutes(timings.sprintRaceMinutes)}
Main race
{formatMinutes(timings.mainRaceMinutes)}
{/* 4. Scoring & drops */}

Scoring & drops

Scoring pattern
{scoringPresetName}
Pattern summary
{scoringPatternSummary}
Drop rule
{dropPolicySummary}
{scoring.customScoringEnabled && (
Custom scoring
Custom scoring flagged
)}
{/* 5. Championships */}

Championships

Enabled championships
{enabledChampionshipsLabels.length > 0 ? ( enabledChampionshipsLabels.map((label) => ( {label} )) ) : ( None enabled yet )}
); }