import { DashboardKpiRow } from '@/components/dashboard/DashboardKpiRow'; import { RecentActivityTable, type ActivityItem } from '@/components/dashboard/RecentActivityTable'; import { TelemetryPanel } from '@/components/dashboard/TelemetryPanel'; import type { DashboardViewData } from '@/lib/view-data/DashboardViewData'; import { routes } from '@/lib/routing/RouteConfig'; import { useRouter } from 'next/navigation'; import { Box } from '@/ui/Box'; import { Button } from '@/ui/Button'; import { Grid } from '@/ui/Grid'; import { Stack } from '@/ui/Stack'; import { Text } from '@/ui/Text'; interface DashboardTemplateProps { viewData: DashboardViewData; onNavigateToRaces: () => void; } /** * DashboardTemplate * * Redesigned as a "Telemetry Workspace" following the Precision Racing Minimal theme. * Composes semantic dashboard components into a high-density data environment. * Complies with architectural constraints by using UI primitives. */ export function DashboardTemplate({ viewData, onNavigateToRaces, }: DashboardTemplateProps) { const router = useRouter(); const { currentDriver, nextRace, upcomingRaces, leagueStandings, feedItems, activeLeaguesCount, hasLeagueStandings, hasFeedItems, } = viewData; const kpiItems = [ { label: 'Rating', value: currentDriver.rating, intent: 'primary' as const }, { label: 'Rank', value: `#${currentDriver.rank}`, intent: 'warning' as const }, { label: 'Starts', value: currentDriver.totalRaces }, { label: 'Wins', value: currentDriver.wins, intent: 'success' as const }, { label: 'Podiums', value: currentDriver.podiums, intent: 'warning' as const }, { label: 'Leagues', value: activeLeaguesCount }, ]; const activityItems: ActivityItem[] = feedItems.map(item => ({ id: item.id, type: item.type.toUpperCase(), description: item.headline, timestamp: item.formattedTime, status: item.type === 'race_result' ? 'success' : 'info' })); return ( {/* KPI Overview */} {/* Main Content Column */} {nextRace && ( Next Event {nextRace.track} {nextRace.car} {nextRace.formattedDate} @ {nextRace.formattedTime} {nextRace.timeUntil} {nextRace.formattedDate} @ {nextRace.formattedTime} )} {hasFeedItems ? ( ) : ( No recent activity recorded. )} {/* Sidebar Column */} {hasLeagueStandings ? ( {leagueStandings.map((standing) => ( router.push(routes.league.detail(standing.leagueId))} > {standing.leagueName} Pos: {standing.position} / {standing.totalDrivers} {standing.points} PTS ))} ) : ( No active championships. )} {upcomingRaces.length > 0 ? ( upcomingRaces.slice(0, 3).map((race) => ( router.push(routes.race.detail(race.id))} > {race.track} {race.timeUntil} {race.car} {race.formattedDate} )) ) : ( No upcoming races. )} ); }