feat(categories): allow disabling preselection
All checks were successful
Staging Build / build (push) Successful in 2m45s

This commit is contained in:
DanielS
2026-07-09 14:10:25 +02:00
parent bffaca1d63
commit 07c7d8c656
4 changed files with 50 additions and 8 deletions

View File

@@ -211,7 +211,7 @@ export function OrderWizard({
return
}
}
if (cat.allow_multiselect) {
if (cat.allow_multiselect || cat.preselect === false) {
init[cat.id] = { productId: null, productIds: [], moduleIds: [] }
} else {
const first = products.find(p => p.category_id === cat.id && p.show_in_abo !== false)
@@ -459,11 +459,19 @@ export function OrderWizard({
}
const newSelections: Record<string, CategorySelection> = {}
categories.forEach(cat => {
const matchingProd = products.find(p =>
p.category_id === cat.id &&
(val === 'one_time' ? p.show_in_kauf !== false : p.show_in_abo !== false)
)
newSelections[cat.id] = { productId: matchingProd?.id ?? null, moduleIds: [] }
if (cat.allow_multiselect || cat.preselect === false) {
newSelections[cat.id] = { productId: null, productIds: [], moduleIds: [] }
} else {
const matchingProd = products.find(p =>
p.category_id === cat.id &&
(val === 'one_time' ? p.show_in_kauf !== false : p.show_in_abo !== false)
)
newSelections[cat.id] = {
productId: matchingProd?.id ?? null,
productIds: matchingProd ? [matchingProd.id] : [],
moduleIds: []
}
}
})
setSelections(newSelections)
}