feat(persoenliche-ausruestung): show catalog category, remove size/date columns, make zustand admin-configurable

This commit is contained in:
Matthias Hochmeister
2026-04-16 08:19:38 +02:00
parent dac0b79b3b
commit 058ee721e8
14 changed files with 282 additions and 96 deletions

View File

@@ -3,7 +3,7 @@ import CheckroomIcon from '@mui/icons-material/Checkroom';
import { useQuery } from '@tanstack/react-query';
import { useNavigate } from 'react-router-dom';
import { personalEquipmentApi } from '../../services/personalEquipment';
import { ZUSTAND_LABELS, ZUSTAND_COLORS } from '../../types/personalEquipment.types';
import type { ZustandOption } from '../../types/personalEquipment.types';
import { WidgetCard } from '../templates/WidgetCard';
import { ItemListSkeleton } from '../templates/SkeletonPresets';
@@ -17,6 +17,15 @@ function PersoenlicheAusruestungWidget() {
retry: 1,
});
const { data: zustandOptions = [] } = useQuery<ZustandOption[]>({
queryKey: ['persoenliche-ausruestung', 'zustand-options'],
queryFn: () => personalEquipmentApi.getZustandOptions(),
staleTime: 5 * 60 * 1000,
});
const getZustandLabel = (key: string) => zustandOptions.find(o => o.key === key)?.label ?? key;
const getZustandColor = (key: string) => zustandOptions.find(o => o.key === key)?.color ?? 'default';
const displayItems = (items ?? []).slice(0, 5);
return (
@@ -43,13 +52,13 @@ function PersoenlicheAusruestungWidget() {
<ListItem key={item.id} disablePadding sx={{ py: 0.5 }}>
<ListItemText
primary={item.bezeichnung}
secondary={[item.kategorie, item.groesse].filter(Boolean).join(' · ') || undefined}
secondary={item.artikel_kategorie_name ?? item.kategorie ?? undefined}
primaryTypographyProps={{ variant: 'body2', noWrap: true }}
secondaryTypographyProps={{ variant: 'caption' }}
/>
<Chip
label={ZUSTAND_LABELS[item.zustand]}
color={ZUSTAND_COLORS[item.zustand]}
label={getZustandLabel(item.zustand)}
color={getZustandColor(item.zustand) as any}
size="small"
variant="outlined"
sx={{ ml: 1, flexShrink: 0 }}