style(wizard): change add-to-basket button label dynamically to Kasse speichern and Kasse anlegen
This commit is contained in:
@@ -307,6 +307,10 @@ export function OrderWizard({
|
|||||||
})
|
})
|
||||||
}, [visibleCategories, selections, products, selectedBillingInterval])
|
}, [visibleCategories, selections, products, selectedBillingInterval])
|
||||||
|
|
||||||
|
const hasActiveSelection = useMemo(() => {
|
||||||
|
return Object.values(selections).some(sel => sel.productId || (sel.productIds && sel.productIds.length > 0))
|
||||||
|
}, [selections])
|
||||||
|
|
||||||
// Product validation errors (requirements and exclusions)
|
// Product validation errors (requirements and exclusions)
|
||||||
const productValidationErrors = useMemo(() => {
|
const productValidationErrors = useMemo(() => {
|
||||||
const errors: string[] = []
|
const errors: string[] = []
|
||||||
@@ -549,8 +553,7 @@ export function OrderWizard({
|
|||||||
|
|
||||||
const nextStep = () => {
|
const nextStep = () => {
|
||||||
if (step === 3 && allCategoriesFilled && productValidationErrors.length === 0) {
|
if (step === 3 && allCategoriesFilled && productValidationErrors.length === 0) {
|
||||||
const hasProduct = Object.values(selections).some(sel => sel.productId || (sel.productIds && sel.productIds.length > 0))
|
if (hasActiveSelection) {
|
||||||
if (hasProduct) {
|
|
||||||
addToBasket()
|
addToBasket()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -680,9 +683,7 @@ export function OrderWizard({
|
|||||||
setIsSubmitting(true)
|
setIsSubmitting(true)
|
||||||
try {
|
try {
|
||||||
let finalItems = [...basketItems]
|
let finalItems = [...basketItems]
|
||||||
const hasProduct = Object.values(selections).some(sel => sel.productId || (sel.productIds && sel.productIds.length > 0))
|
if (hasActiveSelection && allCategoriesFilled && productValidationErrors.length === 0) {
|
||||||
|
|
||||||
if (hasProduct && allCategoriesFilled && productValidationErrors.length === 0) {
|
|
||||||
const currentItem = {
|
const currentItem = {
|
||||||
deviceName: deviceName || (editingIdx !== null ? basketItems[editingIdx]?.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)),
|
||||||
@@ -1558,7 +1559,7 @@ export function OrderWizard({
|
|||||||
onClick={addToBasket}
|
onClick={addToBasket}
|
||||||
disabled={isNextStepDisabled}
|
disabled={isNextStepDisabled}
|
||||||
>
|
>
|
||||||
<UserPlus className="w-4 h-4" /> {editingIdx !== null ? '💾 Änderungen an Kasse speichern' : 'Noch eine Kasse hinzufügen'}
|
<UserPlus className="w-4 h-4" /> {editingIdx !== null ? '💾 Änderungen an Kasse speichern' : (hasActiveSelection ? 'Kasse speichern' : 'Kasse anlegen')}
|
||||||
</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