Fixed bug selecting eating habits
This commit is contained in:
@@ -37,11 +37,7 @@ class SignUpCommand {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$eatingHabit = match ($this->request->eating_habit) {
|
||||
'vegan' => EatingHabit::EATING_HABIT_VEGAN,
|
||||
'vegetarian' => EatingHabit::EATING_HABIT_VEGETARIAN,
|
||||
default => EatingHabit::EATING_HABIT_OMNIVOR,
|
||||
};
|
||||
$eatingHabit = $this->resolveEatingHabit();
|
||||
|
||||
$participantAge = new Age($this->request->birthday);
|
||||
|
||||
@@ -111,6 +107,21 @@ class SignUpCommand {
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ernährungsweise auflösen. Übernommen wird nur ein Slug, den die Veranstaltung anbietet; ohne Angabe (z. B. bei
|
||||
* der Kurzanmeldung) oder bei einem nicht angebotenen Wert gilt "Omnivor".
|
||||
*/
|
||||
private function resolveEatingHabit(): string
|
||||
{
|
||||
$slug = $this->request->eating_habit;
|
||||
|
||||
if ($slug !== '' && $this->request->event->eatingHabits()->where('slug', $slug)->exists()) {
|
||||
return $slug;
|
||||
}
|
||||
|
||||
return EatingHabit::EATING_HABIT_OMNIVOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Badeerlaubnis auflösen. Volljährige brauchen keine Erlaubnis. Für Minderjährige gilt die getroffene Auswahl;
|
||||
* fehlt sie -- weil die Veranstaltung die Badeerlaubnis gar nicht abfragt oder keine Wahl getroffen wurde --,
|
||||
|
||||
@@ -143,7 +143,7 @@ class SignupController extends CommonController {
|
||||
$registrationData['intolerances'],
|
||||
$registrationData['medikamente'],
|
||||
$tetanusVaccination,
|
||||
$registrationData['essgewohnheit'],
|
||||
$registrationData['eatingHabit'] ?? '',
|
||||
$registrationData['badeerlaubnis'],
|
||||
$registrationData['first_aid'],
|
||||
$registrationData['foto']['socialmedia'],
|
||||
|
||||
@@ -13,8 +13,13 @@ export function useSignupForm(event, participantData) {
|
||||
// Für die Aktion freigeschaltete Zahlungsmethoden; ist genau eine aktiv, wird sie vorausgewählt.
|
||||
const activeMethods = (event.paymentMethods ?? []).filter(m => m.active)
|
||||
|
||||
// Vorbelegung mit der Ernährungsweise aus dem Profil, sofern die Veranstaltung sie anbietet, sonst die erste Option.
|
||||
const eatingHabitSlugs = (event.eatingHabits ?? []).map(h => h.data.slug)
|
||||
|
||||
const formData = reactive({
|
||||
eatingHabit: 'EATING_HABIT_VEGAN',
|
||||
eatingHabit: eatingHabitSlugs.includes(participantData.eating_habit)
|
||||
? participantData.eating_habit
|
||||
: (eatingHabitSlugs[0] ?? ''),
|
||||
paymentMethod: activeMethods.length === 1 ? activeMethods[0].slug : null,
|
||||
paymentOptions: {},
|
||||
// Antworten auf die event-spezifischen Teilnahmeoptionen: { [question.key]: option.value }
|
||||
@@ -53,7 +58,6 @@ export function useSignupForm(event, participantData) {
|
||||
intolerances: participantData.intolerances ?? '',
|
||||
medikamente: participantData.medications ?? '',
|
||||
tetanusVaccination: participantData.tetanusVaccination ?? '',
|
||||
essgewohnheit: 'vegetarian',
|
||||
anmerkungen: '',
|
||||
summary_information_correct: false,
|
||||
summary_accept_terms: false,
|
||||
|
||||
Reference in New Issue
Block a user