'use client';
import { DashboardControlBar } from '@/components/dashboard/DashboardControlBar';
import { DashboardKpiRow } from '@/components/dashboard/DashboardKpiRow';
import { DashboardRail } from '@/components/dashboard/DashboardRail';
import { DashboardShell } from '@/components/dashboard/DashboardShell';
import { RecentActivityTable, type ActivityItem } from '@/components/dashboard/RecentActivityTable';
import { TelemetryPanel } from '@/components/dashboard/TelemetryPanel';
import { routes } from '@/lib/routing/RouteConfig';
import type { DashboardViewData } from '@/lib/view-data/DashboardViewData';
import { Avatar } from '@/ui/Avatar';
import { Button } from '@/ui/Button';
import { Grid } from '@/ui/primitives/Grid';
import { IconButton } from '@/ui/IconButton';
import { Box } from '@/ui/primitives/Box';
import { Stack } from '@/ui/primitives/Stack';
import { Text } from '@/ui/Text';
import { Bell, Calendar, LayoutDashboard, Search, Settings, Trophy, Users } from 'lucide-react';
import { useRouter } from 'next/navigation';
interface DashboardTemplateProps {
viewData: DashboardViewData;
}
/**
* 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 }: DashboardTemplateProps) {
const router = useRouter();
const {
currentDriver,
nextRace,
upcomingRaces,
leagueStandings,
feedItems,
activeLeaguesCount,
hasLeagueStandings,
hasFeedItems,
} = viewData;
const kpiItems = [
{ label: 'Rating', value: currentDriver.rating, color: 'var(--color-telemetry)' },
{ label: 'Rank', value: `#${currentDriver.rank}`, color: 'var(--color-warning)' },
{ label: 'Starts', value: currentDriver.totalRaces },
{ label: 'Wins', value: currentDriver.wins, color: 'var(--color-success)' },
{ label: 'Podiums', value: currentDriver.podiums, color: 'var(--color-warning)' },
{ 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'
}));
const railContent = (
GP
router.push(routes.protected.dashboard)}
variant="ghost"
color="primary-accent"
/>
router.push(routes.public.leagues)}
variant="ghost"
color="var(--color-text-low)"
/>
router.push(routes.public.races)}
variant="ghost"
color="var(--color-text-low)"
/>
router.push(routes.public.teams)}
variant="ghost"
color="var(--color-text-low)"
/>
router.push(routes.protected.profile)}
variant="ghost"
color="var(--color-text-low)"
/>
);
const controlBarActions = (
);
return (
}
>
{/* KPI Overview */}
{/* Main Content Column */}
{nextRace && (
Next Event
{nextRace.track}
{nextRace.car}
Starts In
{nextRace.timeUntil}
{nextRace.formattedDate} @ {nextRace.formattedTime}
)}
{hasFeedItems ? (
) : (
No recent activity recorded.
)}
{/* Sidebar Column */}
{hasLeagueStandings ? (
{leagueStandings.map((standing) => (
{standing.leagueName}
Pos: {standing.position} / {standing.totalDrivers}
{standing.points} PTS
))}
) : (
No active championships.
)}
{upcomingRaces.slice(0, 3).map((race) => (
{race.track}
{race.timeUntil}
{race.car}
{race.formattedDate}
))}
);
}