import { Link } from '@tanstack/react-router' import { ChevronRight, Flag as FlagIcon } from 'lucide-react' import type { WeekendBriefingItem, WeekendChampionshipImpact, WeekendContext, WeekendViewState, } from '../../types' import { BriefingStrip, ChampionshipImpactCard, ChampionshipRoundStrip, CountdownDisplay, EventPodium, Flag, } from './shared' import { analysisSessionKey, meetingIdentity } from '../../lib/weekendContext' import { parseScheduleTime } from '../../lib/schedule' const EYEBROW: Record = { between_weekends: 'Between races', post_weekend: 'Post-weekend', season_complete: 'Season complete', } function formatSessionLine(name: string | undefined, start: string | undefined): string { if (!name) return 'Schedule to be confirmed' const date = start ? parseScheduleTime(start) : null if (!date) return name const when = date.toLocaleString('en-GB', { weekday: 'long', hour: '2-digit', minute: '2-digit', hour12: false, }) return `${name} ยท ${when}` } export function BetweenRacesView({ context, now, view, championship, briefing, }: { context: WeekendContext now: Date view: WeekendViewState championship?: WeekendChampionshipImpact briefing: WeekendBriefingItem[] }) { const eyebrow = EYEBROW[view] ?? 'Between races' const previous = context.previous_completed_session const previousMeeting = meetingIdentity(previous?.meeting ?? context.previous_meeting) const nextMeeting = meetingIdentity(context.next_meeting) const nextSession = context.next_session?.session const analysisKey = analysisSessionKey(context) return (
{eyebrow}
{previousMeeting && (

{previousMeeting.meeting_name}

What decided it? {analysisKey ? ( Explore Race Story
)} {nextMeeting ? (

{nextMeeting.meeting_name}

Next event
Next session {formatSessionLine(nextSession?.session_name, nextSession?.date_start)}
Prepare for {nextMeeting.short_name}
) : (

That's a wrap

Off-season

The {context.season} calendar is complete. Explore the season's races or revisit the championship battle while the next schedule is confirmed.

Explore the season
)}
{championship && }
{briefing.length > 0 && }
) }