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])
|
||||
|
||||
const hasActiveSelection = useMemo(() => {
|
||||
return Object.values(selections).some(sel => sel.productId || (sel.productIds && sel.productIds.length > 0))
|
||||
}, [selections])
|
||||
|
||||
// Product validation errors (requirements and exclusions)
|
||||
const productValidationErrors = useMemo(() => {
|
||||
const errors: string[] = []
|
||||
@@ -549,8 +553,7 @@ export function OrderWizard({
|
||||
|
||||
const nextStep = () => {
|
||||
if (step === 3 && allCategoriesFilled && productValidationErrors.length === 0) {
|
||||
const hasProduct = Object.values(selections).some(sel => sel.productId || (sel.productIds && sel.productIds.length > 0))
|
||||
if (hasProduct) {
|
||||
if (hasActiveSelection) {
|
||||
addToBasket()
|
||||
}
|
||||
}
|
||||
@@ -680,9 +683,7 @@ export function OrderWizard({
|
||||
setIsSubmitting(true)
|
||||
try {
|
||||
let finalItems = [...basketItems]
|
||||
const hasProduct = Object.values(selections).some(sel => sel.productId || (sel.productIds && sel.productIds.length > 0))
|
||||
|
||||
if (hasProduct && allCategoriesFilled && productValidationErrors.length === 0) {
|
||||
if (hasActiveSelection && allCategoriesFilled && productValidationErrors.length === 0) {
|
||||
const currentItem = {
|
||||
deviceName: deviceName || (editingIdx !== null ? basketItems[editingIdx]?.deviceName : `Kasse ${basketItems.length + 1}`),
|
||||
selections: JSON.parse(JSON.stringify(selections)),
|
||||
@@ -1558,7 +1559,7 @@ export function OrderWizard({
|
||||
onClick={addToBasket}
|
||||
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>
|
||||
<Separator className="bg-white/10 my-1" />
|
||||
<Button
|
||||
|
||||
Reference in New Issue
Block a user