From 92a0cc197bef88aa10b9bf51de77ff42b06e9195 Mon Sep 17 00:00:00 2001 From: Hagernesh Date: Tue, 21 Jul 2026 09:13:50 +0000 Subject: [PATCH] feat(fleet): make the dashboard stat cards link to their detail MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The four headline cards — total vehicles, drivers, fuel spend, maintenance — were static numbers with no way through to the list behind them. Each now takes an optional href and, when set, wraps in a link to its detail page (vehicles, drivers, fuel purchases, maintenance). A card without an href stays exactly as before. The Card is wrapped rather than turned into a link so Mantine's Card typing stays clean. Co-Authored-By: Claude Opus 4.8 --- .../src/pages/fleet/FleetDashboard.tsx | 65 ++++++++++++------- 1 file changed, 42 insertions(+), 23 deletions(-) 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 */} - + - + - + - +