feat: special treatment of participants with age 0-2 (babies)

This commit is contained in:
Björn Fromme
2025-11-26 15:38:49 +01:00
parent 30704f936a
commit 32bef9a4e9
12 changed files with 615 additions and 15 deletions
+16 -4
View File
@@ -8,12 +8,14 @@ use App\BusProNet\Utility\DirectionMapper;
use App\Form\Service\Abstract\AbstractFieldStateProvider;
use App\Form\Service\Condition\ApplicantCondition;
use App\Form\Service\Condition\AuthenticatedUserPersonalDataCondition;
use App\Form\Service\Condition\BabyAgeCondition;
use App\Form\Service\Condition\BookingEligibilityCondition;
use App\Form\Service\Condition\BulkInsuranceBookingCondition;
use App\Form\Service\Condition\CompositeCondition;
use App\Form\Service\Condition\DateOfBirthProvidedCondition;
use App\Form\Service\Condition\FieldValueCondition;
use App\Form\Service\Condition\FinalBookingOnlyCondition;
use App\Form\Service\Condition\MultipleParticipantsCondition;
use App\Form\Service\Condition\RentalSelectionCondition;
use App\Form\Service\Condition\RoomSelectionCondition;
use App\Form\Service\Condition\ServiceSubTypeCondition;
@@ -142,6 +144,9 @@ class CreateFieldStateProvider extends AbstractFieldStateProvider
// Hide age-dependent fields when no date of birth is provided
$dateOfBirthProvidedCondition = new DateOfBirthProvidedCondition();
// Baby age condition - hide ski pass for babies (0-2 years)
$babyAgeCondition = new BabyAgeCondition();
// Age-dependent service fields are hidden until birth date is provided OR when participant is ineligible
$this->fieldStateConditions['courses'] = [
'hidden' => CompositeCondition::or(
@@ -157,11 +162,15 @@ class CreateFieldStateProvider extends AbstractFieldStateProvider
),
];
// Skipass field - hidden when participant is ineligible OR when no date of birth
// Skipass field - hidden when:
// - No date of birth provided
// - Participant is ineligible (no skipasses for their age)
// - Participant is baby age (0-2 years) - babies don't need ski passes
$this->fieldStateConditions['skiPass'] = [
'hidden' => CompositeCondition::or(
CompositeCondition::not($dateOfBirthProvidedCondition),
$bookingEligibilityCondition
$bookingEligibilityCondition,
$babyAgeCondition
),
];
@@ -184,11 +193,14 @@ class CreateFieldStateProvider extends AbstractFieldStateProvider
// Bulk insurance booking conditions
$bulkInsuranceBookingCondition = new BulkInsuranceBookingCondition();
// Show bulk insurance booking checkbox ONLY for applicant (index 0) and when insurance field is visible
// Show bulk insurance booking checkbox ONLY for applicant (index 0) when:
// - Date of birth is provided
// - There are multiple participants (bulk assignment is meaningless for single participant)
$this->fieldStateConditions['bulkInsuranceBooking'] = [
'hidden' => CompositeCondition::or(
CompositeCondition::not($dateOfBirthProvidedCondition), // Hide until date of birth provided
CompositeCondition::not(new ApplicantCondition()) // Hide for non-applicants
CompositeCondition::not(new ApplicantCondition()), // Hide for non-applicants
CompositeCondition::not(new MultipleParticipantsCondition()) // Hide when only one participant
),
];