fix: auto-save current uncommitted wizard state to basket before editing another item
All checks were successful
Staging Build / build (push) Successful in 2m48s
All checks were successful
Staging Build / build (push) Successful in 2m48s
This commit is contained in:
@@ -585,7 +585,23 @@ export function OrderWizard({
|
|||||||
const editBasketItem = (idx: number) => {
|
const editBasketItem = (idx: number) => {
|
||||||
const item = basketItems[idx]
|
const item = basketItems[idx]
|
||||||
if (!item) return
|
if (!item) return
|
||||||
setBasketItems(prev => prev.filter((_, i) => i !== idx))
|
|
||||||
|
const hasProduct = Object.values(selections).some(sel => sel.productId || (sel.productIds && sel.productIds.length > 0))
|
||||||
|
if (hasProduct) {
|
||||||
|
const currentItem = {
|
||||||
|
deviceName: deviceName || `Kasse ${basketItems.length + 1}`,
|
||||||
|
selections: JSON.parse(JSON.stringify(selections)),
|
||||||
|
moduleQuantities: { ...moduleQuantities },
|
||||||
|
billingInterval: selectedBillingInterval,
|
||||||
|
}
|
||||||
|
setBasketItems(prev => {
|
||||||
|
const filtered = prev.filter((_, i) => i !== idx)
|
||||||
|
return [...filtered, currentItem]
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
setBasketItems(prev => prev.filter((_, i) => i !== idx))
|
||||||
|
}
|
||||||
|
|
||||||
setSelections(item.selections)
|
setSelections(item.selections)
|
||||||
setModuleQuantities(item.moduleQuantities)
|
setModuleQuantities(item.moduleQuantities)
|
||||||
setDeviceName(item.deviceName)
|
setDeviceName(item.deviceName)
|
||||||
|
|||||||
Reference in New Issue
Block a user