feat(wizard): allow deleting devices in step 4 summary and redirect home when empty

This commit is contained in:
DanielS
2026-08-11 23:20:55 +02:00
parent 982897a808
commit 386527a35c
2 changed files with 25 additions and 1 deletions

View File

@@ -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}
/>
</motion.div>
)}