diff --git a/apps/edr-freight-web/backoffice/src/pages/fleet/FleetDashboard.tsx b/apps/edr-freight-web/backoffice/src/pages/fleet/FleetDashboard.tsx index 32341505a..beb16406a 100644 --- a/apps/edr-freight-web/backoffice/src/pages/fleet/FleetDashboard.tsx +++ b/apps/edr-freight-web/backoffice/src/pages/fleet/FleetDashboard.tsx @@ -3,6 +3,7 @@ import { useQuery } from '@tanstack/react-query'; import { Card, Stack, Group, Grid, Text, ThemeIcon, Progress, Badge, Table, RingProgress, Container, Title, Box, Tabs } from '@mantine/core'; import { Truck, Fuel, Wrench, AlertCircle, Users, User, MapPin } from 'lucide-react'; import type { LucideIcon } from 'lucide-react'; +import { Link } from 'react-router-dom'; import Breadcrumbs from '@/components/ui/Breadcrumbs'; import { QUERY_KEYS } from '@/constants/QUERY_KEYS'; import { api } from '@/auth/http'; @@ -51,28 +52,46 @@ interface StatCardProps { value: string | number; color?: string; change?: number; + /** Detail route the card opens. When set the card is a link; otherwise static. */ + href?: string; } -const StatCard = ({ icon: Icon, label, value, color = 'edr-green', change }: StatCardProps) => ( - - - - - - - - - {label} - - - - {value} - - {change && 0 ? 'edr-green' : 'edr-red'} size="lg">{change > 0 ? '+' : ''}{change}%} +const StatCard = ({ icon: Icon, label, value, color = 'edr-green', change, href }: StatCardProps) => { + const card = ( + + + + + - - -); + + + {label} + + + + {value} + + {change && 0 ? 'edr-green' : 'edr-red'} size="lg">{change > 0 ? '+' : ''}{change}%} + + + + ); + + // Wrap in a link to the detail view rather than morphing the Card itself — + // keeps Mantine's Card typing clean. Static when no href. + return href ? ( + + {card} + + ) : ( + card + ); +}; export function FleetDashboard() { const { data: vehicles = [] } = useQuery({ @@ -160,16 +179,16 @@ export function FleetDashboard() { {/* Primary Metrics */} - + - + - + - +