feat(wizard): add showValidationWarning prop to summary sidebar

This commit is contained in:
DanielS
2026-08-27 00:32:09 +02:00
parent 5ea0719225
commit f68d67de43
3 changed files with 31 additions and 11 deletions

View File

@@ -175,6 +175,7 @@ export function OrderWizard({
const [orderNotes, setOrderNotes] = useState<string>('')
const [toast, setToast] = useState<{ message: string; type: 'error' | 'success' } | null>(null)
const [activeCategoryId, setActiveCategoryId] = useState<string | null>(null)
const [showValidationWarning, setShowValidationWarning] = useState(false)
useEffect(() => {
if (toast) {
@@ -545,14 +546,21 @@ export function OrderWizard({
}
const nextStep = () => {
if (step === 3 && allCategoriesFilled && productValidationErrors.length === 0) {
const isDirtyNewDevice = (deviceName.trim() !== '' || licenseNumber.trim() !== '' || Object.values(moduleQuantities).some(q => q > 0)) && editingIdx === null
if (editingIdx !== null) {
addToBasket()
} else if (basketItems.length === 0 && hasActiveSelection) {
addToBasket()
} else if (isDirtyNewDevice && hasActiveSelection) {
addToBasket()
if (step === 3) {
if (isNextStepDisabled && basketItems.length === 0) {
setShowValidationWarning(true)
return
}
setShowValidationWarning(false)
if (allCategoriesFilled && productValidationErrors.length === 0) {
const isDirtyNewDevice = (deviceName.trim() !== '' || licenseNumber.trim() !== '' || Object.values(moduleQuantities).some(q => q > 0)) && editingIdx === null
if (editingIdx !== null) {
addToBasket()
} else if (basketItems.length === 0 && hasActiveSelection) {
addToBasket()
} else if (isDirtyNewDevice && hasActiveSelection) {
addToBasket()
}
}
}
setDirection(1)
@@ -945,7 +953,7 @@ export function OrderWizard({
onClick={() => setActiveCategoryId(cat.id)}
className={`flex items-center gap-2.5 p-2.5 rounded-xl border transition-all duration-300 text-left relative overflow-hidden group ${
isMissingRequired
? 'animate-eye-catcher bg-red-500/10 border-red-500 text-red-400 font-bold shadow-[0_0_20px_rgba(239,68,68,0.4)]'
? 'bg-red-500/10 border-red-500/50 text-red-400 font-bold'
: isActive
? 'bg-primary/10 border-primary text-white shadow-[0_0_15px_rgba(59,130,246,0.2)]'
: 'bg-slate-900/50 border-white/5 text-slate-400 hover:bg-slate-900 hover:border-white/20 hover:text-white'
@@ -1124,6 +1132,7 @@ export function OrderWizard({
addToBasket={addToBasket}
isNextStepDisabled={isNextStepDisabled}
hasActiveSelection={hasActiveSelection}
showValidationWarning={showValidationWarning}
nextStep={nextStep}
prevStep={prevStep}
/>