Compare commits
4 Commits
0b268881a1
...
545b5e93bf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
545b5e93bf | ||
|
|
e9117d34a0 | ||
|
|
d72830412e | ||
|
|
0a9997e98a |
@@ -729,7 +729,7 @@ export function CreateProductDialog({
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
{step < 5 ? (
|
{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
|
Weiter
|
||||||
</Button>
|
</Button>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ import { Label } from "@/components/ui/label"
|
|||||||
|
|
||||||
export function ProductList({ initialProducts, categories }: { initialProducts: Product[], categories: Category[] }) {
|
export function ProductList({ initialProducts, categories }: { initialProducts: Product[], categories: Category[] }) {
|
||||||
const [products, setProducts] = useState(initialProducts)
|
const [products, setProducts] = useState(initialProducts)
|
||||||
const [isGroupedByCategory, setIsGroupedByCategory] = useState(false)
|
const [isGroupedByCategory, setIsGroupedByCategory] = useState(true)
|
||||||
const [showKauf, setShowKauf] = useState(true)
|
const [showKauf, setShowKauf] = useState(true)
|
||||||
const [showAbo, setShowAbo] = useState(true)
|
const [showAbo, setShowAbo] = useState(true)
|
||||||
const [copySourceProduct, setCopySourceProduct] = useState<Product | null>(null)
|
const [copySourceProduct, setCopySourceProduct] = useState<Product | null>(null)
|
||||||
@@ -202,7 +202,7 @@ export function ProductList({ initialProducts, categories }: { initialProducts:
|
|||||||
size="sm"
|
size="sm"
|
||||||
onClick={toggleGroupByCategory}
|
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 ${
|
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" />
|
<ArrowUpDown className="w-4 h-4 mr-2" />
|
||||||
|
|||||||
@@ -148,6 +148,7 @@ export function OrderWizard({
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
const [deviceName, setDeviceName] = useState<string>('')
|
const [deviceName, setDeviceName] = useState<string>('')
|
||||||
|
const [editingIdx, setEditingIdx] = useState<number | null>(null)
|
||||||
|
|
||||||
// Partner-Profil (Fallback)
|
// Partner-Profil (Fallback)
|
||||||
const [customerData] = useState<Partial<Profile>>(initialProfile || {})
|
const [customerData] = useState<Partial<Profile>>(initialProfile || {})
|
||||||
@@ -595,12 +596,23 @@ export function OrderWizard({
|
|||||||
|
|
||||||
const addToBasket = () => {
|
const addToBasket = () => {
|
||||||
const currentItem = {
|
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)),
|
selections: JSON.parse(JSON.stringify(selections)),
|
||||||
moduleQuantities: { ...moduleQuantities },
|
moduleQuantities: { ...moduleQuantities },
|
||||||
billingInterval: selectedBillingInterval,
|
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({})
|
setModuleQuantities({})
|
||||||
setDeviceName('')
|
setDeviceName('')
|
||||||
|
|
||||||
@@ -622,22 +634,7 @@ export function OrderWizard({
|
|||||||
const item = basketItems[idx]
|
const item = basketItems[idx]
|
||||||
if (!item) return
|
if (!item) return
|
||||||
|
|
||||||
const hasProduct = Object.values(selections).some(sel => sel.productId || (sel.productIds && sel.productIds.length > 0))
|
setEditingIdx(idx)
|
||||||
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))
|
|
||||||
}
|
|
||||||
|
|
||||||
setSelections(item.selections)
|
setSelections(item.selections)
|
||||||
setModuleQuantities(item.moduleQuantities)
|
setModuleQuantities(item.moduleQuantities)
|
||||||
setDeviceName(item.deviceName)
|
setDeviceName(item.deviceName)
|
||||||
@@ -645,6 +642,25 @@ export function OrderWizard({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const deleteBasketItem = (idx: number) => {
|
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))
|
setBasketItems(prev => prev.filter((_, i) => i !== idx))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -653,13 +669,20 @@ export function OrderWizard({
|
|||||||
setIsSubmitting(true)
|
setIsSubmitting(true)
|
||||||
try {
|
try {
|
||||||
let finalItems = [...basketItems]
|
let finalItems = [...basketItems]
|
||||||
if (finalItems.length === 0 && allCategoriesFilled && productValidationErrors.length === 0) {
|
const hasProduct = Object.values(selections).some(sel => sel.productId || (sel.productIds && sel.productIds.length > 0))
|
||||||
finalItems.push({
|
|
||||||
deviceName: deviceName || 'Kasse 1',
|
if (hasProduct && allCategoriesFilled && productValidationErrors.length === 0) {
|
||||||
selections,
|
const currentItem = {
|
||||||
moduleQuantities,
|
deviceName: deviceName || (editingIdx !== null ? basketItems[editingIdx]?.deviceName : `Kasse ${basketItems.length + 1}`),
|
||||||
billingInterval: selectedBillingInterval
|
selections: JSON.parse(JSON.stringify(selections)),
|
||||||
})
|
moduleQuantities: { ...moduleQuantities },
|
||||||
|
billingInterval: selectedBillingInterval,
|
||||||
|
}
|
||||||
|
if (editingIdx !== null) {
|
||||||
|
finalItems[editingIdx] = currentItem
|
||||||
|
} else {
|
||||||
|
finalItems.push(currentItem)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (finalItems.length === 0) {
|
if (finalItems.length === 0) {
|
||||||
@@ -715,7 +738,7 @@ export function OrderWizard({
|
|||||||
: 'bg-slate-800 text-slate-400'
|
: 'bg-slate-800 text-slate-400'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
{step > s ? <Check className="w-6 h-6" /> : s}
|
{s}
|
||||||
</div>
|
</div>
|
||||||
<span className={`text-xs font-semibold ${step >= s ? 'text-primary' : 'text-slate-500'}`}>
|
<span className={`text-xs font-semibold ${step >= s ? 'text-primary' : 'text-slate-500'}`}>
|
||||||
{s === 1 ? 'Kunde' : s === 2 ? 'Modell' : s === 3 ? 'Software' : 'Abschluss'}
|
{s === 1 ? 'Kunde' : s === 2 ? 'Modell' : s === 3 ? 'Software' : 'Abschluss'}
|
||||||
@@ -1039,7 +1062,7 @@ export function OrderWizard({
|
|||||||
: 'bg-slate-800 text-slate-400'
|
: 'bg-slate-800 text-slate-400'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
{step > s ? <Check className="w-6 h-6" /> : s}
|
{s}
|
||||||
</div>
|
</div>
|
||||||
<span className={`text-xs font-semibold ${step >= s ? 'text-primary' : 'text-slate-500'}`}>
|
<span className={`text-xs font-semibold ${step >= s ? 'text-primary' : 'text-slate-500'}`}>
|
||||||
{s === 1 ? 'Kunde' : s === 2 ? 'Modell' : s === 3 ? 'Software' : 'Abschluss'}
|
{s === 1 ? 'Kunde' : s === 2 ? 'Modell' : s === 3 ? 'Software' : 'Abschluss'}
|
||||||
@@ -1514,7 +1537,7 @@ export function OrderWizard({
|
|||||||
onClick={addToBasket}
|
onClick={addToBasket}
|
||||||
disabled={isNextStepDisabled}
|
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>
|
</Button>
|
||||||
<Separator className="bg-white/10 my-1" />
|
<Separator className="bg-white/10 my-1" />
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
Reference in New Issue
Block a user