feat: add optional categories - admins can mark categories as optional in the order wizard
This commit is contained in:
@@ -88,9 +88,9 @@ export function OrderWizard({
|
||||
return init
|
||||
})
|
||||
|
||||
// All categories must have a product selected
|
||||
// Only REQUIRED categories must have a product selected
|
||||
const allCategoriesFilled = useMemo(
|
||||
() => categories.every(cat => !!selections[cat.id]?.productId),
|
||||
() => categories.filter(cat => cat.is_required).every(cat => !!selections[cat.id]?.productId),
|
||||
[categories, selections]
|
||||
)
|
||||
|
||||
@@ -234,10 +234,14 @@ export function OrderWizard({
|
||||
<Badge className="ml-auto bg-green-500/20 text-green-400 border border-green-500/30">
|
||||
<Check className="w-3 h-3 mr-1" /> Ausgewählt
|
||||
</Badge>
|
||||
) : (
|
||||
) : cat.is_required ? (
|
||||
<Badge variant="destructive" className="ml-auto opacity-80">
|
||||
<AlertCircle className="w-3 h-3 mr-1" /> Pflichtfeld
|
||||
</Badge>
|
||||
) : (
|
||||
<Badge variant="outline" className="ml-auto border-white/20 text-slate-400">
|
||||
Optional
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -353,8 +357,12 @@ export function OrderWizard({
|
||||
const prod = products.find(p => p.id === sel?.productId)
|
||||
if (!prod) return (
|
||||
<div key={cat.id} className="text-xs text-slate-500 italic flex items-center gap-1">
|
||||
<AlertCircle className="w-3 h-3 text-destructive" />
|
||||
{cat.name}: nicht gewählt
|
||||
{cat.is_required ? (
|
||||
<AlertCircle className="w-3 h-3 text-destructive" />
|
||||
) : (
|
||||
<span className="w-3 h-3 inline-block" />
|
||||
)}
|
||||
{cat.name}: {cat.is_required ? 'nicht gewählt' : 'nicht gewählt (optional)'}
|
||||
</div>
|
||||
)
|
||||
return (
|
||||
@@ -392,7 +400,7 @@ export function OrderWizard({
|
||||
{!allCategoriesFilled && (
|
||||
<p className="text-xs text-destructive flex items-center gap-1">
|
||||
<AlertCircle className="w-3 h-3" />
|
||||
Bitte aus jeder Kategorie einen Artikel wählen.
|
||||
Bitte aus jeder Pflichtkategorie einen Artikel wählen.
|
||||
</p>
|
||||
)}
|
||||
</CardContent>
|
||||
|
||||
Reference in New Issue
Block a user