import type { LeagueAdminScheduleViewData } from '@/lib/view-data/LeagueAdminScheduleViewData'; import { Box } from '@/ui/Box'; import { Button } from '@/ui/Button'; import { Card } from '@/ui/Card'; import { Grid } from '@/ui/Grid'; import { Heading } from '@/ui/Heading'; import { InlineNotice } from '@/ui/InlineNotice'; import { Input } from '@/ui/Input'; import { Select } from '@/ui/Select'; import { Stack } from '@/ui/Stack'; import { Surface } from '@/ui/Surface'; import { Text } from '@/ui/Text'; interface LeagueAdminScheduleTemplateProps { viewData: LeagueAdminScheduleViewData; onSeasonChange: (seasonId: string) => void; onPublishToggle: () => void; onAddOrSave: () => void; onEdit: (raceId: string) => void; onDelete: (raceId: string) => void; onCancelEdit: () => void; // Form state track: string; car: string; scheduledAtIso: string; editingRaceId: string | null; // Mutation states isPublishing: boolean; isSaving: boolean; isDeleting: string | null; error: string | null; // Form setters setTrack: (value: string) => void; setCar: (value: string) => void; setScheduledAtIso: (value: string) => void; } export function LeagueAdminScheduleTemplate({ viewData, onSeasonChange, onPublishToggle, onAddOrSave, onEdit, onDelete, onCancelEdit, track, car, scheduledAtIso, editingRaceId, isPublishing, isSaving, isDeleting, error, setTrack, setCar, setScheduledAtIso, }: LeagueAdminScheduleTemplateProps) { const typedViewData = viewData as LeagueAdminScheduleViewData & { seasons: Array<{ seasonId: string; name: string }>; }; const { races, seasons, seasonId, published } = typedViewData; const isEditing = editingRaceId !== null; const publishedLabel = published ? 'Published' : 'Unpublished'; const selectedSeasonLabel = seasons.find((s: {seasonId: string; name: string}) => s.seasonId === seasonId)?.name ?? seasonId; return ( {error && ( )} Schedule Admin Create, edit, and publish season races. Season setTrack(e.target.value)} placeholder="Track name" /> Car setCar(e.target.value)} placeholder="Car name" /> Scheduled At (ISO) setScheduledAtIso(e.target.value)} placeholder="2025-01-01T12:00:00.000Z" /> {isEditing && ( )} Races {races.length > 0 ? ( {races.map((race) => ( {race.name} {race.scheduledAt} ))} ) : ( No races yet. )} ); }