mirror of
https://github.com/AmanTahiliani/box-box.git
synced 2026-08-07 19:56:18 -04:00
Replace the static weekend band with a three-state hero (live, upcoming, between weekends) driven by heroState() and existing page queries. Between-weekend podium uses the existing race-hub endpoint for the last ingested race session since championship hub does not expose finish positions. Co-authored-by: Cursor <cursoragent@cursor.com>
28 lines
885 B
TypeScript
28 lines
885 B
TypeScript
import type { Session } from '../types'
|
|
import { sessionEndTime, sessionStartTime, type FocusMeetingKind } from './schedule'
|
|
|
|
export type HeroStateKind = 'live' | 'upcoming' | 'between'
|
|
|
|
export interface HeroStateInputs {
|
|
now: Date
|
|
liveActive: boolean
|
|
currentSession: Session | null
|
|
focusKind: FocusMeetingKind | null
|
|
}
|
|
|
|
export function classifySessionStatus(session: Session, now: Date): 'live' | 'done' | 'upcoming' {
|
|
const start = sessionStartTime(session)
|
|
const end = sessionEndTime(session)
|
|
if (start && end && now >= start && now < end) return 'live'
|
|
if (start && now >= start) return 'done'
|
|
return 'upcoming'
|
|
}
|
|
|
|
export function heroState(inputs: HeroStateInputs): HeroStateKind {
|
|
const { liveActive, currentSession, focusKind } = inputs
|
|
|
|
if (liveActive || currentSession) return 'live'
|
|
if (focusKind === 'current') return 'upcoming'
|
|
return 'between'
|
|
}
|