'use client'; import { FormEvent } from 'react'; import { LeagueReviewSummary } from '@/components/leagues/LeagueReviewSummary'; import { Card } from '@/ui/Card'; import { Heading } from '@/ui/Heading'; import { Input } from '@/ui/Input'; import { Box } from '@/ui/Box'; import { Button } from '@/ui/Button'; import { Grid } from '@/ui/Grid'; import { Stack } from '@/ui/Stack'; import { Text } from '@/ui/Text'; import { Icon } from '@/ui/Icon'; import { AlertCircle, Check, ChevronLeft, ChevronRight, FileText, Loader2, Sparkles, } from 'lucide-react'; import { LeagueBasicsSection } from '@/components/leagues/LeagueBasicsSection'; import { LeagueDropSection } from '@/components/leagues/LeagueDropSection'; import { ChampionshipsSection, ScoringPatternSection } from '@/components/leagues/LeagueScoringSection'; import { LeagueStewardingSection } from '@/components/leagues/LeagueStewardingSection'; import { LeagueStructureSection } from '@/components/leagues/LeagueStructureSection'; import { LeagueTimingsSection } from '@/components/leagues/LeagueTimingsSection'; import { LeagueVisibilitySection } from '@/components/leagues/LeagueVisibilitySection'; import type { LeagueScoringPresetViewModel } from '@/lib/view-models/LeagueScoringPresetViewModel'; import type { WizardErrors } from '@/lib/types/WizardErrors'; import { TemplateProps } from '@/lib/contracts/components/ComponentContracts'; import { ViewData } from '@/lib/contracts/view-data/ViewData'; export type Step = 1 | 2 | 3 | 4 | 5 | 6 | 7; interface CreateLeagueWizardTemplateProps extends TemplateProps { step: Step; steps: any[]; form: any; errors: WizardErrors; loading: boolean; presetsLoading: boolean; presets: LeagueScoringPresetViewModel[]; highestCompletedStep: number; onGoToStep: (step: Step) => void; onFormChange: (form: any) => void; onSubmit: (e: FormEvent) => void; onNextStep: () => void; onPreviousStep: () => void; onScoringPresetChange: (id: string) => void; onToggleCustomScoring: () => void; getStepTitle: (step: Step) => string; getStepSubtitle: (step: Step) => string; getStepContextLabel: (step: Step) => string; } export function CreateLeagueWizardTemplate({ step, steps, form, errors, loading, presetsLoading, presets, highestCompletedStep, onGoToStep, onFormChange, onSubmit, onNextStep, onPreviousStep, onScoringPresetChange, onToggleCustomScoring, getStepTitle, getStepSubtitle, getStepContextLabel, }: CreateLeagueWizardTemplateProps) { const currentStepData = steps.find((s) => s.id === step); const CurrentStepIcon = currentStepData?.icon ?? FileText; return ( {/* Header with icon */} Create a new league We'll also set up your first season in {steps.length} easy steps. A league is your long-term brand. Each season is a block of races you can run again and again. {/* Desktop Progress Bar */} {/* Background track */} {/* Progress fill */} {steps.map((wizardStep) => { const isCompleted = wizardStep.id < step; const isCurrent = wizardStep.id === step; const isAccessible = wizardStep.id <= highestCompletedStep; const StepIcon = wizardStep.icon; return ( onGoToStep(wizardStep.id)} disabled={!isAccessible} display="flex" flexDirection="col" alignItems="center" bg="transparent" cursor={isAccessible ? 'pointer' : 'not-allowed'} opacity={!isAccessible ? 0.6 : 1} > {isCompleted ? ( ) : ( )} {wizardStep.label} ); })} {/* Main Card */} {/* Step header */} {getStepTitle(step)} {getStepContextLabel(step)} {getStepSubtitle(step)} Step {step} / {steps.length} {/* Step content */} {step === 1 && ( First season Name the first season that will run in this league. Season name onFormChange({ ...form, seasonName: e.target.value, }) } placeholder="e.g., Season 1 (2025)" /> Seasons are the individual competitive runs inside your league. You can run Season 2, Season 3, or parallel seasons later. )} {step === 2 && ( )} {step === 3 && ( Applies to: First season of this league. )} {step === 4 && ( Applies to: First season of this league. )} {step === 5 && ( Applies to: First season of this league. {errors.submit && ( {errors.submit} )} )} {step === 6 && ( Applies to: First season of this league. )} {step === 7 && ( {errors.submit && ( {errors.submit} )} )} {/* Navigation */} {step < 7 ? ( ) : ( )} {/* Helper text */} This will create your league and its first season. You can edit both later. ); }