From 386527a35c371ae2f7322c47d7044b92df0c5cda Mon Sep 17 00:00:00 2001 From: DanielS Date: Tue, 11 Aug 2026 23:20:55 +0200 Subject: [PATCH] feat(wizard): allow deleting devices in step 4 summary and redirect home when empty --- shop/components/order-wizard.tsx | 9 ++++++++- shop/components/wizard/step-summary.tsx | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/shop/components/order-wizard.tsx b/shop/components/order-wizard.tsx index 2bbc0f0..78d37d8 100644 --- a/shop/components/order-wizard.tsx +++ b/shop/components/order-wizard.tsx @@ -718,13 +718,19 @@ export function OrderWizard({ resetSels[cat.id] = { productId: first?.id ?? null, productIds: first ? [first.id] : [], moduleIds: [] } } }) - setSelections(resetSels) } else if (editingIdx !== null && idx < editingIdx) { setEditingIdx(editingIdx - 1) } setBasketItems(prev => prev.filter((_, i) => i !== idx)) } + const handleDeleteFromSummary = (idx: number) => { + deleteBasketItem(idx) + if (basketItems.length - 1 <= 0) { + router.push('/') + } + } + const handleSubmit = async () => { if (isSubmitting) return setIsSubmitting(true) @@ -1137,6 +1143,7 @@ export function OrderWizard({ setOrderNotes={setOrderNotes} onEditBasketItem={handleEditFromSummary} onAddNewBasketItem={handleAddAnotherFromSummary} + onDeleteBasketItem={handleDeleteFromSummary} /> )} diff --git a/shop/components/wizard/step-summary.tsx b/shop/components/wizard/step-summary.tsx index de76dde..11a40ee 100644 --- a/shop/components/wizard/step-summary.tsx +++ b/shop/components/wizard/step-summary.tsx @@ -34,6 +34,7 @@ interface StepSummaryProps { setOrderNotes: (notes: string) => void onEditBasketItem?: (idx: number) => void onAddNewBasketItem?: () => void + onDeleteBasketItem?: (idx: number) => void } function CategoryIcon({ icon, className }: { icon?: string | null; className?: string }) { @@ -67,6 +68,7 @@ export function StepSummary({ setOrderNotes, onEditBasketItem, onAddNewBasketItem, + onDeleteBasketItem, }: StepSummaryProps) { return (
@@ -206,6 +208,21 @@ export function StepSummary({ Bearbeiten )} + {onDeleteBasketItem && ( + + )}