feat(wizard): allow deleting devices in step 4 summary and redirect home when empty
This commit is contained in:
@@ -718,13 +718,19 @@ export function OrderWizard({
|
|||||||
resetSels[cat.id] = { productId: first?.id ?? null, productIds: first ? [first.id] : [], moduleIds: [] }
|
resetSels[cat.id] = { productId: first?.id ?? null, productIds: first ? [first.id] : [], moduleIds: [] }
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
setSelections(resetSels)
|
|
||||||
} else if (editingIdx !== null && idx < editingIdx) {
|
} else if (editingIdx !== null && idx < editingIdx) {
|
||||||
setEditingIdx(editingIdx - 1)
|
setEditingIdx(editingIdx - 1)
|
||||||
}
|
}
|
||||||
setBasketItems(prev => prev.filter((_, i) => i !== idx))
|
setBasketItems(prev => prev.filter((_, i) => i !== idx))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleDeleteFromSummary = (idx: number) => {
|
||||||
|
deleteBasketItem(idx)
|
||||||
|
if (basketItems.length - 1 <= 0) {
|
||||||
|
router.push('/')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (isSubmitting) return
|
if (isSubmitting) return
|
||||||
setIsSubmitting(true)
|
setIsSubmitting(true)
|
||||||
@@ -1137,6 +1143,7 @@ export function OrderWizard({
|
|||||||
setOrderNotes={setOrderNotes}
|
setOrderNotes={setOrderNotes}
|
||||||
onEditBasketItem={handleEditFromSummary}
|
onEditBasketItem={handleEditFromSummary}
|
||||||
onAddNewBasketItem={handleAddAnotherFromSummary}
|
onAddNewBasketItem={handleAddAnotherFromSummary}
|
||||||
|
onDeleteBasketItem={handleDeleteFromSummary}
|
||||||
/>
|
/>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ interface StepSummaryProps {
|
|||||||
setOrderNotes: (notes: string) => void
|
setOrderNotes: (notes: string) => void
|
||||||
onEditBasketItem?: (idx: number) => void
|
onEditBasketItem?: (idx: number) => void
|
||||||
onAddNewBasketItem?: () => void
|
onAddNewBasketItem?: () => void
|
||||||
|
onDeleteBasketItem?: (idx: number) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
function CategoryIcon({ icon, className }: { icon?: string | null; className?: string }) {
|
function CategoryIcon({ icon, className }: { icon?: string | null; className?: string }) {
|
||||||
@@ -67,6 +68,7 @@ export function StepSummary({
|
|||||||
setOrderNotes,
|
setOrderNotes,
|
||||||
onEditBasketItem,
|
onEditBasketItem,
|
||||||
onAddNewBasketItem,
|
onAddNewBasketItem,
|
||||||
|
onDeleteBasketItem,
|
||||||
}: StepSummaryProps) {
|
}: StepSummaryProps) {
|
||||||
return (
|
return (
|
||||||
<div className="grid grid-cols-1 lg:grid-cols-12 gap-6 h-full items-stretch text-left">
|
<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
|
<Icons.Pencil className="w-3 h-3" /> Bearbeiten
|
||||||
</Button>
|
</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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user