Compare commits

...

4 Commits

Author SHA1 Message Date
DanielS
545b5e93bf style(admin): change wizard next button text to black
All checks were successful
Staging Build / build (push) Successful in 3m2s
2026-07-10 14:43:36 +02:00
DanielS
e9117d34a0 style(admin): set category grouping to true by default and color button blue when active 2026-07-10 14:43:11 +02:00
DanielS
d72830412e refactor(wizard): improve basket CRUD and submit lifecycle with editingIdx state 2026-07-10 14:40:49 +02:00
DanielS
0a9997e98a style(wizard): show numbers instead of check icons in progress stepper 2026-07-10 11:18:40 +02:00
3 changed files with 54 additions and 31 deletions

View File

@@ -729,7 +729,7 @@ export function CreateProductDialog({
</div>
<div className="flex gap-2">
{step < 5 ? (
<Button type="button" onClick={nextStep} className="bg-primary hover:bg-primary/90 text-white">
<Button type="button" onClick={nextStep} className="bg-primary hover:bg-primary/90 text-black font-medium">
Weiter
</Button>
) : (

View File

@@ -38,7 +38,7 @@ import { Label } from "@/components/ui/label"
export function ProductList({ initialProducts, categories }: { initialProducts: Product[], categories: Category[] }) {
const [products, setProducts] = useState(initialProducts)
const [isGroupedByCategory, setIsGroupedByCategory] = useState(false)
const [isGroupedByCategory, setIsGroupedByCategory] = useState(true)
const [showKauf, setShowKauf] = useState(true)
const [showAbo, setShowAbo] = useState(true)
const [copySourceProduct, setCopySourceProduct] = useState<Product | null>(null)
@@ -202,7 +202,7 @@ export function ProductList({ initialProducts, categories }: { initialProducts:
size="sm"
onClick={toggleGroupByCategory}
className={`border-slate-200 dark:border-white/10 hover:bg-slate-100 dark:hover:bg-white/10 text-slate-700 dark:text-white ${
isGroupedByCategory ? 'bg-primary/10 border-primary text-primary hover:bg-primary/20 dark:bg-primary/20 dark:border-primary dark:text-primary-foreground' : ''
isGroupedByCategory ? 'bg-blue-600 text-white border-blue-600 hover:bg-blue-700 hover:text-white dark:bg-blue-600 dark:text-white dark:hover:bg-blue-700' : ''
}`}
>
<ArrowUpDown className="w-4 h-4 mr-2" />

View File

@@ -148,6 +148,7 @@ export function OrderWizard({
})
})
const [deviceName, setDeviceName] = useState<string>('')
const [editingIdx, setEditingIdx] = useState<number | null>(null)
// Partner-Profil (Fallback)
const [customerData] = useState<Partial<Profile>>(initialProfile || {})
@@ -595,12 +596,23 @@ export function OrderWizard({
const addToBasket = () => {
const currentItem = {
deviceName: deviceName || `Kasse ${basketItems.length + 1}`,
deviceName: deviceName || (editingIdx !== null ? basketItems[editingIdx]?.deviceName : `Kasse ${basketItems.length + 1}`),
selections: JSON.parse(JSON.stringify(selections)),
moduleQuantities: { ...moduleQuantities },
billingInterval: selectedBillingInterval,
}
setBasketItems(prev => [...prev, currentItem])
if (editingIdx !== null) {
setBasketItems(prev => {
const next = [...prev]
next[editingIdx] = currentItem
return next
})
setEditingIdx(null)
} else {
setBasketItems(prev => [...prev, currentItem])
}
setModuleQuantities({})
setDeviceName('')
@@ -622,22 +634,7 @@ export function OrderWizard({
const item = basketItems[idx]
if (!item) return
const hasProduct = Object.values(selections).some(sel => sel.productId || (sel.productIds && sel.productIds.length > 0))
if (hasProduct) {
const currentItem = {
deviceName: deviceName || `Kasse ${basketItems.length + 1}`,
selections: JSON.parse(JSON.stringify(selections)),
moduleQuantities: { ...moduleQuantities },
billingInterval: selectedBillingInterval,
}
setBasketItems(prev => {
const filtered = prev.filter((_, i) => i !== idx)
return [...filtered, currentItem]
})
} else {
setBasketItems(prev => prev.filter((_, i) => i !== idx))
}
setEditingIdx(idx)
setSelections(item.selections)
setModuleQuantities(item.moduleQuantities)
setDeviceName(item.deviceName)
@@ -645,6 +642,25 @@ export function OrderWizard({
}
const deleteBasketItem = (idx: number) => {
if (editingIdx === idx) {
setEditingIdx(null)
setModuleQuantities({})
setDeviceName('')
const resetSels: Record<string, CategorySelection> = {}
categories.forEach(cat => {
const isVisible = selectedBillingInterval === 'one_time' ? cat.show_in_kauf !== false : cat.show_in_abo !== false
if (!isVisible || cat.allow_multiselect || cat.preselect === false) {
resetSels[cat.id] = { productId: null, productIds: [], moduleIds: [] }
} else {
const first = products.find(p => p.category_id === cat.id && (selectedBillingInterval === 'one_time' ? p.show_in_kauf !== false : p.show_in_abo !== false))
resetSels[cat.id] = { productId: first?.id ?? null, productIds: first ? [first.id] : [], moduleIds: [] }
}
})
setSelections(resetSels)
} else if (editingIdx !== null && idx < editingIdx) {
setEditingIdx(editingIdx - 1)
}
setBasketItems(prev => prev.filter((_, i) => i !== idx))
}
@@ -653,13 +669,20 @@ export function OrderWizard({
setIsSubmitting(true)
try {
let finalItems = [...basketItems]
if (finalItems.length === 0 && allCategoriesFilled && productValidationErrors.length === 0) {
finalItems.push({
deviceName: deviceName || 'Kasse 1',
selections,
moduleQuantities,
billingInterval: selectedBillingInterval
})
const hasProduct = Object.values(selections).some(sel => sel.productId || (sel.productIds && sel.productIds.length > 0))
if (hasProduct && allCategoriesFilled && productValidationErrors.length === 0) {
const currentItem = {
deviceName: deviceName || (editingIdx !== null ? basketItems[editingIdx]?.deviceName : `Kasse ${basketItems.length + 1}`),
selections: JSON.parse(JSON.stringify(selections)),
moduleQuantities: { ...moduleQuantities },
billingInterval: selectedBillingInterval,
}
if (editingIdx !== null) {
finalItems[editingIdx] = currentItem
} else {
finalItems.push(currentItem)
}
}
if (finalItems.length === 0) {
@@ -715,7 +738,7 @@ export function OrderWizard({
: 'bg-slate-800 text-slate-400'
}`}
>
{step > s ? <Check className="w-6 h-6" /> : s}
{s}
</div>
<span className={`text-xs font-semibold ${step >= s ? 'text-primary' : 'text-slate-500'}`}>
{s === 1 ? 'Kunde' : s === 2 ? 'Modell' : s === 3 ? 'Software' : 'Abschluss'}
@@ -1039,7 +1062,7 @@ export function OrderWizard({
: 'bg-slate-800 text-slate-400'
}`}
>
{step > s ? <Check className="w-6 h-6" /> : s}
{s}
</div>
<span className={`text-xs font-semibold ${step >= s ? 'text-primary' : 'text-slate-500'}`}>
{s === 1 ? 'Kunde' : s === 2 ? 'Modell' : s === 3 ? 'Software' : 'Abschluss'}
@@ -1514,7 +1537,7 @@ export function OrderWizard({
onClick={addToBasket}
disabled={isNextStepDisabled}
>
<UserPlus className="w-4 h-4" /> Noch eine Kasse hinzufügen
<UserPlus className="w-4 h-4" /> {editingIdx !== null ? 'Kasse aktualisieren' : 'Noch eine Kasse hinzufügen'}
</Button>
<Separator className="bg-white/10 my-1" />
<Button