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>
)}

View File

@@ -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 (
<div className="grid grid-cols-1 lg:grid-cols-12 gap-6 h-full items-stretch text-left">
@@ -206,6 +208,21 @@ export function StepSummary({
<Icons.Pencil className="w-3 h-3" /> Bearbeiten
</Button>
)}
{onDeleteBasketItem && (
<Button
type="button"
variant="ghost"
size="sm"
onClick={(e) => {
e.stopPropagation()
onDeleteBasketItem(itemIdx)
}}
className="h-7 px-2 text-xs text-slate-400 hover:text-red-400 hover:bg-red-500/20 gap-1 rounded-lg"
title="Kasse löschen"
>
<Icons.Trash2 className="w-3 h-3" /> Löschen
</Button>
)}
</div>
</div>