mirror of
https://github.com/AmanTahiliani/box-box.git
synced 2026-08-07 19:56:18 -04:00
Address the independent review blockers on PR #80 after rebasing onto the authoritative #72 Weekend Context API. - Replace the invented frontend WeekendContext with the exact backend contract (temporal_state, previous/focus/next meetings, previous_completed/active/next/ default_analysis sessions with availability). Every valid canonical payload now maps to a designed state via a total resolveViewState; a well-formed response can never fall through to the limited-data placeholder. - Make the canonical read the single source of truth: useWeekendContext no longer fans out to season/meetings/per-weekend/OpenF1/live queries. Only supplementary championship + news reads run, and only once the canonical context resolves. - Fix the Prepare/analysis flow: /preview is a stable alias that renders the preparation surface (PreSessionView) instead of redirecting back to the same between-races screen. - One primary navigation system per breakpoint: the mobile top-bar links are hidden so the bottom bar is the sole primary nav, and Admin is moved out of every Primary landmark into an operator-utilities toolbar. - Add Vitest coverage for the contract mapping, every temporal state, loading/ error/limited surfaces, the no-fanout guarantee, the /preview CTA, and the nav hierarchy; add hermetic Playwright journeys (seeded + injected canonical payloads), 390/768/1440 overflow checks, and Weekend visual snapshots. Retire the stale Command Center specs/snapshots. Co-authored-by: Cursor <cursoragent@cursor.com>
57 lines
2.3 KiB
TypeScript
57 lines
2.3 KiB
TypeScript
import { Link } from '@tanstack/react-router'
|
|
import { ChevronRight } from 'lucide-react'
|
|
import type { WeekendContext } from '../../types'
|
|
import { RacePreviewPage } from '../../pages/RacePreviewPage'
|
|
import { ChampionshipRoundStrip, CountdownDisplay, Flag, SessionRail, railNodes } from './shared'
|
|
import { meetingIdentity } from '../../lib/weekendContext'
|
|
|
|
/**
|
|
* PreSessionView folds the race preview surface into the Weekend home so there is
|
|
* no separate Preview destination. It reuses the existing preview page content and
|
|
* frames it with the next-session countdown and compact season navigation. It also
|
|
* backs the /preview alias, so saved preview links resolve here instead of looping.
|
|
*/
|
|
export function PreSessionView({ context, now }: { context: WeekendContext; now: Date }) {
|
|
const meeting = meetingIdentity(context.next_meeting ?? context.focus_meeting)
|
|
const next = context.next_session?.session
|
|
const nextStart = next?.date_start ?? meeting?.date_start
|
|
const nodes = railNodes(
|
|
context.previous_completed_session,
|
|
context.active_session,
|
|
context.next_session,
|
|
)
|
|
|
|
return (
|
|
<div className="wk-pre" data-testid="weekend-pre-session" data-state="pre_session">
|
|
<div className="wk-eyebrow mono" data-testid="wk-eyebrow">Pre-session</div>
|
|
|
|
{meeting && (
|
|
<header className="wk-pre-head" data-testid="wk-pre-head">
|
|
<div className="wk-event-id">
|
|
<Flag code={meeting.country_code} flag={meeting.country_flag} />
|
|
<h1 className="wk-sessions-title">{meeting.meeting_name}</h1>
|
|
</div>
|
|
<div className="wk-pre-countdown">
|
|
<span className="wk-next-label mono">{next?.session_name ?? 'Next session'}</span>
|
|
<CountdownDisplay target={nextStart} now={now} />
|
|
</div>
|
|
<Link to="/live" className="wk-cta wk-cta-ghost" data-testid="wk-pre-live">
|
|
Live timing <ChevronRight size={14} aria-hidden="true" />
|
|
</Link>
|
|
</header>
|
|
)}
|
|
|
|
{nodes.length > 0 && <SessionRail nodes={nodes} />}
|
|
|
|
<div className="wk-pre-preview" data-testid="wk-pre-preview">
|
|
<RacePreviewPage />
|
|
</div>
|
|
|
|
<ChampionshipRoundStrip
|
|
round={context.championship_round}
|
|
total={context.total_championship_rounds}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|