diff --git a/shop/components/order-wizard.tsx b/shop/components/order-wizard.tsx index 7b3d510..7a2c803 100644 --- a/shop/components/order-wizard.tsx +++ b/shop/components/order-wizard.tsx @@ -310,6 +310,17 @@ export function OrderWizard({ // Product validation errors (requirements and exclusions) const productValidationErrors = useMemo(() => { const errors: string[] = [] + + // Check for duplicate device names + const currentName = deviceName.trim() || (editingIdx !== null ? basketItems[editingIdx]?.deviceName : `Kasse ${basketItems.length + 1}`) + const isDuplicate = basketItems.some((item, idx) => { + if (editingIdx !== null && idx === editingIdx) return false + return item.deviceName.toLowerCase().trim() === currentName.toLowerCase().trim() + }) + if (isDuplicate) { + errors.push(`Gerätename "${currentName}" existiert bereits im Warenkorb. Bitte einen anderen Namen wählen.`) + } + const selectedProductIds: string[] = [] Object.values(selections).forEach(s => { if (s.productIds && s.productIds.length > 0) { @@ -349,7 +360,7 @@ export function OrderWizard({ }) return errors - }, [selections, products]) + }, [selections, products, deviceName, basketItems, editingIdx]) const isNextStepDisabled = !allCategoriesFilled || productValidationErrors.length > 0