Handling of event addons
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
// Zentrale Schrittreihenfolge des Anmelde-Wizards. Einige Schritte sind optional und werden
|
||||
// übersprungen, wenn sie für das Event nicht zutreffen (Zusatzoptionen, Teilnahmeoptionen).
|
||||
// Der Zahlungsschritt wird separat in useSignupForm anhand des berechneten Betrags übersprungen.
|
||||
export const STEP_AGE = 1
|
||||
export const STEP_CONTACT = 2
|
||||
export const STEP_PERSONAL = 3
|
||||
export const STEP_ARRIVAL = 4
|
||||
export const STEP_REGISTRATION = 5
|
||||
export const STEP_ADDONS = 6
|
||||
export const STEP_PARTICIPATION_OPTIONS = 7
|
||||
export const STEP_PHOTO = 8
|
||||
export const STEP_ALLERGIES = 9
|
||||
export const STEP_PAYMENT = 10
|
||||
export const STEP_SUMMARY = 11
|
||||
|
||||
// Ob ein (optionaler) Schritt für dieses Event angezeigt wird.
|
||||
export function stepVisible(event, step) {
|
||||
if (step === STEP_ADDONS) {
|
||||
return (event.addons?.length ?? 0) > 0
|
||||
}
|
||||
|
||||
if (step === STEP_PARTICIPATION_OPTIONS) {
|
||||
return (event.participationOptions?.length ?? 0) > 0
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// Nächster sichtbarer Schritt nach `step` (überspringt ausgeblendete optionale Schritte).
|
||||
export function nextVisibleFrom(event, step) {
|
||||
let candidate = step + 1
|
||||
while (candidate < STEP_SUMMARY && !stepVisible(event, candidate)) {
|
||||
candidate++
|
||||
}
|
||||
return candidate
|
||||
}
|
||||
|
||||
// Vorheriger sichtbarer Schritt vor `step`.
|
||||
export function prevVisibleFrom(event, step) {
|
||||
let candidate = step - 1
|
||||
while (candidate > STEP_AGE && !stepVisible(event, candidate)) {
|
||||
candidate--
|
||||
}
|
||||
return candidate
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import {reactive, ref} from 'vue'
|
||||
import axios from 'axios'
|
||||
import {STEP_PAYMENT, STEP_SUMMARY} from './stepFlow.js'
|
||||
|
||||
export function useSignupForm(event, participantData) {
|
||||
const currentStep = ref(1)
|
||||
@@ -16,6 +17,8 @@ export function useSignupForm(event, participantData) {
|
||||
eatingHabit: 'EATING_HABIT_VEGAN',
|
||||
paymentMethod: activeMethods.length === 1 ? activeMethods[0].slug : null,
|
||||
paymentOptions: {},
|
||||
// Antworten auf die event-spezifischen Teilnahmeoptionen: { [question.key]: option.value }
|
||||
participationOptions: {},
|
||||
userId: participantData.id,
|
||||
eventId: event.id,
|
||||
vorname: participantData.firstname ?? '',
|
||||
@@ -57,6 +60,8 @@ export function useSignupForm(event, participantData) {
|
||||
|
||||
const summaryAmount = ref('')
|
||||
const summaryAmountValue = ref(0)
|
||||
const summaryBaseAmount = ref('')
|
||||
const summaryAddonLines = ref([])
|
||||
|
||||
const fetchAmount = async () => {
|
||||
summaryLoading.value = true
|
||||
@@ -74,15 +79,13 @@ export function useSignupForm(event, participantData) {
|
||||
})
|
||||
summaryAmount.value = res.data.amount
|
||||
summaryAmountValue.value = Number(res.data.amountValue ?? 0)
|
||||
summaryBaseAmount.value = res.data.baseAmount ?? ''
|
||||
summaryAddonLines.value = res.data.addons ?? []
|
||||
} finally {
|
||||
summaryLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// Steps: ... 8 Allergien, 9 Zahlungsart, 10 Zusammenfassung.
|
||||
const STEP_PAYMENT = 9
|
||||
const STEP_SUMMARY = 10
|
||||
|
||||
const goToStep = async (step) => {
|
||||
if (step === STEP_PAYMENT) {
|
||||
// Betrag ermitteln: Bei 0 € wird die Zahlungsart-Auswahl übersprungen.
|
||||
@@ -129,6 +132,8 @@ export function useSignupForm(event, participantData) {
|
||||
submitResult,
|
||||
summaryLoading,
|
||||
summaryAmount,
|
||||
summaryAmountValue
|
||||
summaryAmountValue,
|
||||
summaryBaseAmount,
|
||||
summaryAddonLines
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user