fix(wizard): prevent duplicate register item addition on step transition
All checks were successful
Staging Build / build (push) Successful in 3m4s

This commit is contained in:
DanielS
2026-08-18 16:26:39 +02:00
parent 8f3d6e5569
commit 409466af9b

View File

@@ -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(