feat: implement category flags, drop global tables, fix sidebar sticky layout
All checks were successful
Staging Build / build (push) Successful in 2m48s
All checks were successful
Staging Build / build (push) Successful in 2m48s
This commit is contained in:
@@ -593,31 +593,54 @@ export function OrderWizard({
|
||||
function selectProduct(catId: string, productId: string) {
|
||||
setSelections(prev => {
|
||||
const cat = categories.find(c => c.id === catId)
|
||||
|
||||
// Build updated selection for this category
|
||||
let updatedCatSel: CategorySelection
|
||||
if (cat?.allow_multiselect) {
|
||||
const currentIds = prev[catId]?.productIds || []
|
||||
const nextIds = currentIds.includes(productId)
|
||||
? currentIds.filter(id => id !== productId)
|
||||
: [...currentIds, productId]
|
||||
return {
|
||||
...prev,
|
||||
[catId]: {
|
||||
productId: nextIds[0] || null,
|
||||
productIds: nextIds,
|
||||
moduleIds: prev[catId]?.moduleIds || []
|
||||
}
|
||||
updatedCatSel = {
|
||||
productId: nextIds[0] || null,
|
||||
productIds: nextIds,
|
||||
moduleIds: prev[catId]?.moduleIds || []
|
||||
}
|
||||
} else {
|
||||
const isCurrentlyChecked = prev[catId]?.productId === productId
|
||||
const nextId = isCurrentlyChecked ? null : productId
|
||||
return {
|
||||
...prev,
|
||||
[catId]: {
|
||||
productId: nextId,
|
||||
productIds: nextId ? [nextId] : [],
|
||||
moduleIds: []
|
||||
}
|
||||
updatedCatSel = {
|
||||
productId: nextId,
|
||||
productIds: nextId ? [nextId] : [],
|
||||
moduleIds: []
|
||||
}
|
||||
}
|
||||
|
||||
// If this category resets others, rebuild all other categories to their initial state
|
||||
if (cat?.resets_others) {
|
||||
const resetSels: Record<string, CategorySelection> = {}
|
||||
categories.forEach(c => {
|
||||
if (c.id === catId) {
|
||||
resetSels[c.id] = updatedCatSel
|
||||
} else {
|
||||
const isVisible = selectedBillingInterval === 'one_time' ? c.show_in_kauf !== false : c.show_in_abo !== false
|
||||
if (!isVisible || c.allow_multiselect || c.preselect === false) {
|
||||
resetSels[c.id] = { productId: null, productIds: [], moduleIds: [] }
|
||||
} else {
|
||||
const first = products.find(p =>
|
||||
p.category_id === c.id &&
|
||||
(selectedBillingInterval === 'one_time' ? p.show_in_kauf !== false : p.show_in_abo !== false)
|
||||
)
|
||||
resetSels[c.id] = { productId: first?.id ?? null, productIds: first ? [first.id] : [], moduleIds: [] }
|
||||
}
|
||||
}
|
||||
})
|
||||
// Also reset module quantities for other categories
|
||||
setModuleQuantities({})
|
||||
return resetSels
|
||||
}
|
||||
|
||||
return { ...prev, [catId]: updatedCatSel }
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -69,12 +69,12 @@ export function SummarySidebar({
|
||||
prevStep,
|
||||
}: SummarySidebarProps) {
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<Card className="glass-dark border-primary/20 sticky top-[20vh] backdrop-blur-lg bg-slate-950/75">
|
||||
<CardHeader>
|
||||
<div className="sticky top-1/2 -translate-y-1/2 max-h-[75vh] flex flex-col">
|
||||
<Card className="glass-dark border-primary/20 backdrop-blur-lg bg-slate-950/75 flex flex-col max-h-[75vh]">
|
||||
<CardHeader className="shrink-0">
|
||||
<CardTitle className="text-white">Zusammenfassung</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<CardContent className="space-y-4 flex-1 overflow-y-auto subpixel-antialiased scrollbar-thin scrollbar-thumb-white/10 scrollbar-track-transparent">
|
||||
{visibleCategories.map(cat => {
|
||||
const sel = selections[cat.id]
|
||||
const selectedProds: Product[] = []
|
||||
@@ -261,7 +261,7 @@ export function SummarySidebar({
|
||||
</div>
|
||||
)}
|
||||
</CardContent>
|
||||
<CardFooter className="flex flex-col gap-3">
|
||||
<CardFooter className="flex flex-col gap-3 shrink-0">
|
||||
<div className="w-full space-y-2">
|
||||
<Label htmlFor="device-name" className="text-xs text-slate-400">Kassenname (optional)</Label>
|
||||
<Input
|
||||
|
||||
Reference in New Issue
Block a user