rework internal order system

This commit is contained in:
Matthias Hochmeister
2026-03-24 13:28:46 +01:00
parent 50d963120a
commit 9a52e41372
9 changed files with 198 additions and 33 deletions

View File

@@ -49,7 +49,7 @@ interface EigenschaftFieldsProps {
function EigenschaftFields({ eigenschaften, values, onChange }: EigenschaftFieldsProps) {
if (eigenschaften.length === 0) return null;
return (
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 1, ml: 2, mt: 0.5 }}>
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 1, ml: 2, mt: 1, pl: 1.5, borderLeft: '2px solid', borderColor: 'divider' }}>
{eigenschaften.map(e => (
<Box key={e.id} sx={{ display: 'flex', gap: 1, alignItems: 'center' }}>
{e.typ === 'options' && e.optionen && e.optionen.length > 0 ? (
@@ -390,6 +390,15 @@ function DetailModal({ requestId, onClose, showAdminActions, showEditButton, can
onError: () => showError('Fehler beim Verknüpfen'),
});
const geliefertMut = useMutation({
mutationFn: ({ positionId, geliefert }: { positionId: number; geliefert: boolean }) =>
ausruestungsanfrageApi.updatePositionGeliefert(positionId, geliefert),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['ausruestungsanfrage'] });
},
onError: () => showError('Fehler beim Aktualisieren'),
});
const startEditing = () => {
if (!detail) return;
setEditBezeichnung(detail.anfrage.bezeichnung || '');
@@ -522,7 +531,7 @@ function DetailModal({ requestId, onClose, showAdminActions, showEditButton, can
<Box sx={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 1.5 }}>
{anfrage!.anfrager_name && (
<Box>
<Typography variant="caption" color="text.secondary">Anfrager</Typography>
<Typography variant="caption" color="text.secondary">Anfrage r</Typography>
<Typography variant="body2" fontWeight={500}>{anfrage!.anfrager_name}</Typography>
</Box>
)}
@@ -558,6 +567,7 @@ function DetailModal({ requestId, onClose, showAdminActions, showEditButton, can
<Table size="small">
<TableHead>
<TableRow>
{showAdminActions && <TableCell padding="checkbox">Geliefert</TableCell>}
<TableCell>Artikel</TableCell>
<TableCell align="right">Menge</TableCell>
<TableCell>Details</TableCell>
@@ -565,9 +575,19 @@ function DetailModal({ requestId, onClose, showAdminActions, showEditButton, can
</TableHead>
<TableBody>
{detail.positionen.map(p => (
<TableRow key={p.id}>
<TableRow key={p.id} sx={p.geliefert ? { opacity: 0.5 } : undefined}>
{showAdminActions && (
<TableCell padding="checkbox">
<Checkbox
size="small"
checked={p.geliefert}
disabled={geliefertMut.isPending}
onChange={(_, checked) => geliefertMut.mutate({ positionId: p.id, geliefert: checked })}
/>
</TableCell>
)}
<TableCell>
<Typography variant="body2" fontWeight={500}>{p.bezeichnung}</Typography>
<Typography variant="body2" fontWeight={500} sx={p.geliefert ? { textDecoration: 'line-through' } : undefined}>{p.bezeichnung}</Typography>
{p.eigenschaften && p.eigenschaften.length > 0 && (
<Box sx={{ display: 'flex', gap: 0.5, flexWrap: 'wrap', mt: 0.5 }}>
{p.eigenschaften.map(e => (
@@ -1118,7 +1138,7 @@ function MeineAnfragenTab() {
<Table size="small">
<TableHead>
<TableRow>
<TableCell>Anfrage</TableCell>
<TableCell>Anfrage ID</TableCell>
<TableCell>Bezeichnung</TableCell>
<TableCell>Status</TableCell>
<TableCell>Positionen</TableCell>
@@ -1357,9 +1377,9 @@ function AlleAnfragenTab() {
<Table size="small">
<TableHead>
<TableRow>
<TableCell>Anfrage</TableCell>
<TableCell>Anfrage ID</TableCell>
<TableCell>Bezeichnung</TableCell>
<TableCell>Anfrager</TableCell>
<TableCell>Anfrage r</TableCell>
<TableCell>Status</TableCell>
<TableCell>Positionen</TableCell>
<TableCell>Erstellt am</TableCell>