'use client'; import React from 'react'; import Image from 'next/image'; import Link from 'next/link'; import { Calendar, Trophy, Users, Star, Clock, Flag, ChevronRight, Target, Award, Activity, Play, Medal, UserPlus, } from 'lucide-react'; import Card from '@/components/ui/Card'; import Button from '@/components/ui/Button'; import { StatCard } from '@/components/dashboard/StatCard'; import { LeagueStandingItem } from '@/components/dashboard/LeagueStandingItem'; import { UpcomingRaceItem } from '@/components/dashboard/UpcomingRaceItem'; import { FriendItem } from '@/components/dashboard/FriendItem'; import { FeedItemRow } from '@/components/dashboard/FeedItemRow'; import { useDashboardOverview } from '@/hooks/useDashboardService'; import { getCountryFlag } from '@/lib/utilities/country'; import { getGreeting, timeUntil } from '@/lib/utilities/time'; export default function DashboardPage() { const { data: dashboardData, isLoading, error } = useDashboardOverview(); if (isLoading) { return (
Loading dashboard...
); } if (error || !dashboardData) { return (
Failed to load dashboard
); } const currentDriver = dashboardData.currentDriver; const nextRace = dashboardData.nextRace; const upcomingRaces = dashboardData.upcomingRaces; const leagueStandingsSummaries = dashboardData.leagueStandings; const feedSummary = { items: dashboardData.feedItems }; const friends = dashboardData.friends; const activeLeaguesCount = dashboardData.activeLeaguesCount; const { totalRaces, wins, podiums, rating, globalRank, consistency } = currentDriver; return (
{/* Hero Section */}
{/* Background Pattern */}
{/* Welcome Message */}
{currentDriver.name}

{getGreeting()},

{currentDriver.name} {getCountryFlag(currentDriver.country)}

{rating}
#{globalRank}
{totalRaces} races completed
{/* Quick Actions */}
{/* Quick Stats Row */}
{/* Main Content */}
{/* Left Column - Main Content */}
{/* Next Race Card */} {nextRace && (
Next Race
{nextRace.isMyLeague && ( Your League )}

{nextRace.track}

{nextRace.car}

{nextRace.scheduledAt.toLocaleDateString('en-US', { weekday: 'long', month: 'short', day: 'numeric', })} {nextRace.scheduledAt.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', })}

Starts in

{timeUntil(nextRace.scheduledAt)}

)} {/* League Standings Preview */} {leagueStandingsSummaries.length > 0 && (

Your Championship Standings

View all
{leagueStandingsSummaries.map(({ leagueId, leagueName, position, points, totalDrivers }) => ( ))}
)} {/* Activity Feed */}

Recent Activity

{feedSummary.items.length > 0 ? (
{feedSummary.items.slice(0, 5).map((item) => ( ))}
) : (

No activity yet

Join leagues and add friends to see activity here

)}
{/* Right Column - Sidebar */}
{/* Upcoming Races */}

Upcoming Races

View all
{upcomingRaces.length > 0 ? (
{upcomingRaces.slice(0, 5).map((race) => ( ))}
) : (

No upcoming races

)}
{/* Friends */}

Friends

{friends.length} friends
{friends.length > 0 ? (
{friends.slice(0, 6).map((friend) => ( ))} {friends.length > 6 && ( +{friends.length - 6} more )}
) : (

No friends yet

)}
); }