From eb82fe29b7e2beb7550d2bc56669d5189bdc2c1c Mon Sep 17 00:00:00 2001 From: Matthias Hochmeister Date: Fri, 27 Mar 2026 12:28:25 +0100 Subject: [PATCH] add linking between internal and external orders --- .../pages/AusruestungsanfrageZuBestellung.tsx | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/frontend/src/pages/AusruestungsanfrageZuBestellung.tsx b/frontend/src/pages/AusruestungsanfrageZuBestellung.tsx index 7178c9f..b190c8f 100644 --- a/frontend/src/pages/AusruestungsanfrageZuBestellung.tsx +++ b/frontend/src/pages/AusruestungsanfrageZuBestellung.tsx @@ -116,7 +116,7 @@ export default function AusruestungsanfrageZuBestellung() { // ── Derived: progress ── const assignedCount = positionen.filter(p => assignments[p.id] != null).length; - const allAssigned = positionen.length > 0 && assignedCount === positionen.length; + const skippedCount = positionen.length - assignedCount; // ── Mutations ── const createOrdersMut = useMutation({ @@ -154,8 +154,10 @@ export default function AusruestungsanfrageZuBestellung() { }); // ── Handlers ── + const canSubmit = vendorGroups.length > 0 && !createOrdersMut.isPending; + const handleSubmit = () => { - if (!allAssigned) return; + if (!canSubmit) return; const orders = vendorGroups.map(g => ({ lieferant_id: g.lieferantId, bezeichnung: orderNames[g.lieferantId] || `Anfrage – ${g.lieferantName}`, @@ -225,8 +227,8 @@ export default function AusruestungsanfrageZuBestellung() { 0 ? 'primary' : 'default'} + variant="outlined" /> @@ -235,7 +237,7 @@ export default function AusruestungsanfrageZuBestellung() { variant="determinate" value={positionen.length > 0 ? (assignedCount / positionen.length) * 100 : 0} sx={{ mb: 3, borderRadius: 2, height: 6 }} - color={allAssigned ? 'success' : 'primary'} + color="primary" /> {/* ── Items table ── */} @@ -258,7 +260,7 @@ export default function AusruestungsanfrageZuBestellung() { ? vendors.find(v => v.id === assignment.lieferantId) ?? null : null; return ( - + {pos.bezeichnung} {pos.notizen && ( @@ -355,16 +357,21 @@ export default function AusruestungsanfrageZuBestellung() { {/* ── Bottom action bar ── */} - {!allAssigned && positionen.length > 0 && ( - - {positionen.length - assignedCount} Artikel {positionen.length - assignedCount === 1 ? 'hat' : 'haben'} noch keinen Lieferanten. + {skippedCount > 0 && assignedCount > 0 && ( + + {skippedCount} Artikel {skippedCount === 1 ? 'ist' : 'sind'} auf Lager und {skippedCount === 1 ? 'wird' : 'werden'} nicht bestellt. + + )} + {assignedCount === 0 && positionen.length > 0 && ( + + Mindestens einem Artikel einen Lieferanten zuweisen, um Bestellungen zu erstellen. )}