diff --git a/frontend/src/components/atemschutz/AtemschutzDashboardCard.tsx b/frontend/src/components/atemschutz/AtemschutzDashboardCard.tsx index 952651a..7c32163 100644 --- a/frontend/src/components/atemschutz/AtemschutzDashboardCard.tsx +++ b/frontend/src/components/atemschutz/AtemschutzDashboardCard.tsx @@ -6,10 +6,9 @@ import { Card, CardContent, CircularProgress, - Link, Typography, } from '@mui/material'; -import { Link as RouterLink } from 'react-router-dom'; +import { useNavigate } from 'react-router-dom'; import { useQuery } from '@tanstack/react-query'; import { atemschutzApi } from '../../services/atemschutz'; import { useCountUp } from '../../hooks/useCountUp'; @@ -22,6 +21,7 @@ interface AtemschutzDashboardCardProps { const AtemschutzDashboardCard: React.FC = ({ hideWhenEmpty = false, }) => { + const navigate = useNavigate(); const { data: stats, isLoading, isError } = useQuery({ queryKey: ['atemschutz-stats'], queryFn: () => atemschutzApi.getStats(), @@ -68,7 +68,7 @@ const AtemschutzDashboardCard: React.FC = ({ if (hideWhenEmpty && allGood) return null; return ( - + navigate('/atemschutz')}> Atemschutz @@ -124,18 +124,6 @@ const AtemschutzDashboardCard: React.FC = ({ Alle Atemschutzträger einsatzbereit )} - - {/* Link to management page */} - - - Zur Verwaltung - - ); diff --git a/frontend/src/components/dashboard/AusruestungsanfrageWidget.tsx b/frontend/src/components/dashboard/AusruestungsanfrageWidget.tsx index 905d476..0587116 100644 --- a/frontend/src/components/dashboard/AusruestungsanfrageWidget.tsx +++ b/frontend/src/components/dashboard/AusruestungsanfrageWidget.tsx @@ -55,12 +55,15 @@ function AusruestungsanfrageWidget() { Keine Anfragen vorhanden. ) : ( - 0 ? 'warning' : 'default'} variant="outlined" /> - 0 ? 'info' : 'default'} variant="outlined" /> {overview.unhandled_count > 0 && ( )} - + {overview.pending_count > 0 && ( + + )} + {overview.approved_count > 0 && ( + + )} )} diff --git a/frontend/src/components/dashboard/BestellungenWidget.tsx b/frontend/src/components/dashboard/BestellungenWidget.tsx index 684eb9b..f3e8c03 100644 --- a/frontend/src/components/dashboard/BestellungenWidget.tsx +++ b/frontend/src/components/dashboard/BestellungenWidget.tsx @@ -1,4 +1,4 @@ -import { Card, CardContent, Typography, Box, Chip, List, ListItem, ListItemText, Divider, Skeleton } from '@mui/material'; +import { Card, CardContent, Typography, Box, Chip, Skeleton } from '@mui/material'; import { LocalShipping } from '@mui/icons-material'; import { useQuery } from '@tanstack/react-query'; import { useNavigate } from 'react-router-dom'; @@ -20,13 +20,18 @@ function BestellungenWidget() { (o) => !['abgeschlossen'].includes(o.status) ); + // Group open orders by status, keep only non-zero counts + const statusCounts = (Object.keys(BESTELLUNG_STATUS_LABELS) as BestellungStatus[]) + .filter((s) => s !== 'abgeschlossen') + .map((s) => ({ status: s, count: openOrders.filter((o) => o.status === s).length })) + .filter((s) => s.count > 0); + if (isLoading) { return ( Bestellungen - - + ); @@ -45,61 +50,27 @@ function BestellungenWidget() { ); } - if (openOrders.length === 0) { - return ( - - - Bestellungen - - - Keine offenen Bestellungen - - - - ); - } - return ( - + navigate('/bestellungen')}> - + Bestellungen - + - - {openOrders.slice(0, 5).map((order, idx) => ( - - {idx > 0 && } - navigate(`/bestellungen/${order.id}`)} - > - - - - - ))} - - {openOrders.length > 5 && ( - navigate('/bestellungen')} - > - Alle {openOrders.length} Bestellungen anzeigen - + {statusCounts.length === 0 ? ( + Keine offenen Bestellungen + ) : ( + + {statusCounts.map(({ status, count }) => ( + + ))} + )} diff --git a/frontend/src/components/equipment/EquipmentDashboardCard.tsx b/frontend/src/components/equipment/EquipmentDashboardCard.tsx index 06dba80..8216569 100644 --- a/frontend/src/components/equipment/EquipmentDashboardCard.tsx +++ b/frontend/src/components/equipment/EquipmentDashboardCard.tsx @@ -6,10 +6,9 @@ import { Card, CardContent, CircularProgress, - Link, Typography, } from '@mui/material'; -import { Link as RouterLink } from 'react-router-dom'; +import { useNavigate } from 'react-router-dom'; import { useQuery } from '@tanstack/react-query'; import { equipmentApi } from '../../services/equipment'; import { useCountUp } from '../../hooks/useCountUp'; @@ -22,6 +21,7 @@ interface EquipmentDashboardCardProps { const EquipmentDashboardCard: React.FC = ({ hideWhenEmpty = false, }) => { + const navigate = useNavigate(); const { data: stats, isLoading, isError } = useQuery({ queryKey: ['equipment-stats'], queryFn: () => equipmentApi.getStats(), @@ -68,7 +68,7 @@ const EquipmentDashboardCard: React.FC = ({ if (hideWhenEmpty && allGood) return null; return ( - + navigate('/ausruestung')}> Ausrüstung @@ -134,18 +134,6 @@ const EquipmentDashboardCard: React.FC = ({ Alle Ausrüstung einsatzbereit )} - - {/* Link to management page */} - - - Zur Verwaltung - - ); diff --git a/frontend/src/components/vehicles/VehicleDashboardCard.tsx b/frontend/src/components/vehicles/VehicleDashboardCard.tsx index b2152a3..dfc29ab 100644 --- a/frontend/src/components/vehicles/VehicleDashboardCard.tsx +++ b/frontend/src/components/vehicles/VehicleDashboardCard.tsx @@ -6,10 +6,9 @@ import { Card, CardContent, CircularProgress, - Link, Typography, } from '@mui/material'; -import { Link as RouterLink } from 'react-router-dom'; +import { useNavigate } from 'react-router-dom'; import { useQuery } from '@tanstack/react-query'; import { vehiclesApi } from '../../services/vehicles'; import { equipmentApi } from '../../services/equipment'; @@ -24,6 +23,7 @@ interface VehicleDashboardCardProps { const VehicleDashboardCard: React.FC = ({ hideWhenEmpty = false, }) => { + const navigate = useNavigate(); const { data: stats, isLoading: statsLoading, isError: statsError } = useQuery({ queryKey: ['vehicle-stats'], queryFn: () => vehiclesApi.getStats(), @@ -85,7 +85,7 @@ const VehicleDashboardCard: React.FC = ({ if (hideWhenEmpty && allGood) return null; return ( - + navigate('/fahrzeuge')}> Fahrzeuge @@ -143,18 +143,6 @@ const VehicleDashboardCard: React.FC = ({ Alle Fahrzeuge einsatzbereit )} - - {/* Link to management page */} - - - Zur Verwaltung - - );