mirror of
https://github.com/AmanTahiliani/box-box.git
synced 2026-08-07 19:56:18 -04:00
feat(frontend): add session-aware Command Center hero (#14)
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>
This commit is contained in:
27
frontend/src/lib/hero.ts
Normal file
27
frontend/src/lib/hero.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
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'
|
||||
}
|
||||
Reference in New Issue
Block a user