feat: auto-booking services
addresses #869cfcptv
This commit is contained in:
@@ -85,7 +85,7 @@ class Step2Controller extends AbstractController
|
||||
$this->roomAssignmentService->assignRoomsIfNeeded($bookingCreateDto);
|
||||
|
||||
// Preselect mandatory services
|
||||
$this->bookingService->preselectMandatoryServices($bookingCreateDto);
|
||||
$this->bookingService->preselectDefaultServices($bookingCreateDto);
|
||||
|
||||
// Save BookingDto to session
|
||||
$this->bookingService->saveBookingDto($request, $bookingCreateDto, BookingDto::MODE_CREATE);
|
||||
@@ -149,18 +149,19 @@ class Step2Controller extends AbstractController
|
||||
$form = $this->createParticipantForm($bookingDto, $index);
|
||||
|
||||
$form->handleRequest($request);
|
||||
$isSubmitted = $form->isSubmitted();
|
||||
|
||||
// Detect dummy data fill token — render pre-filled form immediately, skipping validation
|
||||
$isDummyDataFill = $this
|
||||
->dummyDataFillService
|
||||
->isTokenMatch($bookingDto->participants[$index], $bookingDto->getMode())
|
||||
;
|
||||
if (true === $form->isSubmitted() && true === $isDummyDataFill) {
|
||||
if (true === $isSubmitted && true === $isDummyDataFill) {
|
||||
$this->dummyDataFillService->fill($bookingDto->participants[$index], $index);
|
||||
|
||||
// Keep behavior consistent with cards view: newly filled participant data
|
||||
// (especially dateOfBirth) must immediately trigger mandatory service preselection.
|
||||
$this->bookingService->preselectMandatoryServices($bookingDto);
|
||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
||||
|
||||
$bookingDto->bookingStatus = Constants::BOOKING_STATUS_OPEN;
|
||||
$this->bookingService->saveBookingDto($request, $bookingDto, BookingDto::MODE_CREATE);
|
||||
@@ -171,10 +172,16 @@ class Step2Controller extends AbstractController
|
||||
return $this->renderParticipantForm($form, $index, $bookingDto);
|
||||
}
|
||||
|
||||
if (true === $isSubmitted) {
|
||||
// Re-run default preselection after participant form input changes (e.g. DOB).
|
||||
// This ensures auto-book defaults are applied as soon as eligibility becomes known.
|
||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
||||
}
|
||||
|
||||
// Collect notifications from field handlers (run during PRE_SUBMIT)
|
||||
$notifications = $this->collectAndClearNotifications($bookingDto);
|
||||
|
||||
if (true === $form->isSubmitted() && true === $form->isValid()) {
|
||||
if (true === $isSubmitted && true === $form->isValid()) {
|
||||
// Save BookingDto to session
|
||||
$this->bookingService->saveBookingDto($request, $bookingDto, BookingDto::MODE_CREATE);
|
||||
|
||||
|
||||
@@ -122,13 +122,19 @@ trait ParticipantCardFlowTrait
|
||||
int $index,
|
||||
string $refreshRouteName,
|
||||
): Response {
|
||||
$refreshFormOptions = ['validation_groups' => false];
|
||||
|
||||
// Create form with validation disabled
|
||||
$form = $this->createParticipantForm($bookingDto, $index, [
|
||||
'validation_groups' => false,
|
||||
]);
|
||||
$form = $this->createParticipantForm($bookingDto, $index, $refreshFormOptions);
|
||||
|
||||
$form->handleRequest($request);
|
||||
|
||||
// Refresh endpoint is POST-only and always processes submitted participant data.
|
||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
||||
|
||||
// Recreate form so the rendered state reflects any new auto-preselections.
|
||||
$form = $this->createParticipantForm($bookingDto, $index, $refreshFormOptions);
|
||||
|
||||
// Collect notifications from field handlers
|
||||
$notifications = $this->collectAndClearNotifications($bookingDto);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user