From 409466af9b5a149b59e8e9f7ad6a449c8ad7242a Mon Sep 17 00:00:00 2001 From: DanielS Date: Tue, 18 Aug 2026 16:26:39 +0200 Subject: [PATCH] fix(wizard): prevent duplicate register item addition on step transition --- shop/components/order-wizard.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/shop/components/order-wizard.tsx b/shop/components/order-wizard.tsx index cd55aa3..2310919 100644 --- a/shop/components/order-wizard.tsx +++ b/shop/components/order-wizard.tsx @@ -542,7 +542,12 @@ export function OrderWizard({ const nextStep = () => { if (step === 3 && allCategoriesFilled && productValidationErrors.length === 0) { - if (hasActiveSelection) { + const isDirtyNewDevice = deviceName.trim() !== '' || licenseNumber.trim() !== '' || Object.values(moduleQuantities).some(q => q > 0) + if (editingIdx !== null) { + addToBasket() + } else if (basketItems.length === 0 && hasActiveSelection) { + addToBasket() + } else if (isDirtyNewDevice && hasActiveSelection) { addToBasket() } } @@ -738,7 +743,8 @@ export function OrderWizard({ setIsSubmitting(true) try { let finalItems = [...basketItems] - if (hasActiveSelection && allCategoriesFilled && productValidationErrors.length === 0) { + const isDirtyNewDevice = deviceName.trim() !== '' || licenseNumber.trim() !== '' || Object.values(moduleQuantities).some(q => q > 0) + if ((editingIdx !== null || basketItems.length === 0 || isDirtyNewDevice) && hasActiveSelection && allCategoriesFilled && productValidationErrors.length === 0) { const normLicense = licenseNumber.trim().toUpperCase() if (normLicense) { const isDuplicateInBasket = basketItems.some(