/** * @ai-summary Main dashboard screen showing vehicle fleet roster with health indicators */ import React, { useState } from 'react'; import { Box, Dialog, DialogTitle, DialogContent, IconButton, Skeleton, Typography, useMediaQuery, useTheme } from '@mui/material'; import WarningAmberRoundedIcon from '@mui/icons-material/WarningAmberRounded'; import DirectionsCarRoundedIcon from '@mui/icons-material/DirectionsCarRounded'; import CloseIcon from '@mui/icons-material/Close'; import { VehicleRosterCard } from './VehicleRosterCard'; import { ActionBar } from './ActionBar'; import { useVehicleRoster } from '../hooks/useDashboardData'; import { GlassCard } from '../../../shared-minimal/components/mobile/GlassCard'; import { Button } from '../../../shared-minimal/components/Button'; import { PendingAssociationBanner } from '../../email-ingestion/components/PendingAssociationBanner'; import { PendingAssociationList } from '../../email-ingestion/components/PendingAssociationList'; import { MobileScreen } from '../../../core/store'; import { Vehicle } from '../../vehicles/types/vehicles.types'; interface DashboardScreenProps { // eslint-disable-next-line @typescript-eslint/no-explicit-any -- matches navigation store type signature onNavigate?: (screen: MobileScreen, metadata?: Record) => void; onVehicleClick?: (vehicle: Vehicle) => void; onViewMaintenance?: () => void; onAddVehicle?: () => void; } const RosterSkeleton: React.FC = () => (
{[0, 1, 2, 3].map(i => (
))}
); export const DashboardScreen: React.FC = ({ onNavigate, onVehicleClick, onAddVehicle, }) => { const theme = useTheme(); const isSmall = useMediaQuery(theme.breakpoints.down('sm')); const [showPendingReceipts, setShowPendingReceipts] = useState(false); const { data: roster, vehicles, isLoading, error } = useVehicleRoster(); const handleAddVehicle = onAddVehicle ?? (() => onNavigate?.('Vehicles')); const handleLogFuel = () => onNavigate?.('Log Fuel'); const handleVehicleClick = (vehicleId: string) => { const vehicle = vehicles?.find(v => v.id === vehicleId); if (vehicle && onVehicleClick) { onVehicleClick(vehicle); } }; // Error state if (error) { return (

Unable to Load Dashboard

There was an error loading your dashboard data

); } // Loading state if (isLoading || !roster) { return (
Your Fleet
); } // Empty state - no vehicles if (roster.length === 0) { return (

Welcome to MotoVaultPro

Get started by adding your first vehicle to track fuel logs, maintenance, and more

); } // Main dashboard view return (
{/* Pending Receipts Banner */} setShowPendingReceipts(true)} /> {/* Heading + Action Bar */}
Your Fleet
{/* Vehicle Roster Grid */}
{roster.map(rosterData => ( ))}
{/* Pending Receipts Dialog */} setShowPendingReceipts(false)} fullScreen={isSmall} maxWidth="sm" fullWidth PaperProps={{ sx: { maxHeight: isSmall ? '100%' : '90vh', m: isSmall ? 0 : 2, }, }} > Pending Receipts setShowPendingReceipts(false)} sx={{ minWidth: 44, minHeight: 44 }} >
); };