fix: refresh live room availability during create flow

This commit is contained in:
Björn Fromme committed 2026-07-14 11:25:23 +02:00
1 parent a73e8a593f
commit cdce7d57e0
26 files changed
+1976 -54

No files matched your search

@@ -13,8 +13,6 @@ use App\Service\BookingSessionManager;
use App\Service\ParticipantDataPrefiller;
use App\Service\ParticipantFormSupport;
use App\Service\RoomPricingCalculator;
use App\Service\TravelDataProvider;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -23,7 +21,7 @@ use Symfony\Component\Routing\Attribute\Route;
/**
* Handles participant editing and refresh actions within booking step 2.
*/
class Step2ParticipantController extends AbstractController
class Step2ParticipantController extends AbstractBookingCreateController
{
use HxTrait;
@@ -31,7 +29,6 @@ class Step2ParticipantController extends AbstractController
private readonly BookingConfigurator $bookingService,
private readonly BookingSessionManager $bookingSessionService,
private readonly BookingCreateContextFactory $createContextFactory,
private readonly TravelDataProvider $travelDataService,
private readonly ParticipantDataPrefiller $prepopulationService,
private readonly ParticipantFormSupport $participantFormSupportService,
) {
@@ -51,48 +48,53 @@ class Step2ParticipantController extends AbstractController
if ($result instanceof Response) {
return $result;
}
$bookingDto = $result;
$bookingCreateDto = $result;
$this->participantFormSupportService->ensureParticipantExists($bookingDto, $index);
$this->participantFormSupportService->ensureParticipantExists($bookingCreateDto, $index);
$this->travelDataService->enrichWithFreshAvailabilities($bookingDto->travel);
if ($redirect = $this->redirectIfRoomSelectionsStale($request, $bookingCreateDto, $this->bookingSessionService)) {
return $redirect;
}
$form = $this->createParticipantForm($bookingDto, $index);
$this->bookingService->updateBookingStatusFromRoomSelection($bookingCreateDto);
$this->bookingSessionService->saveBookingDto($request, $bookingCreateDto, BookingDto::MODE_CREATE);
$form = $this->createParticipantForm($bookingCreateDto, $index);
$form->handleRequest($request);
$isSubmitted = $form->isSubmitted();
$isDummyDataFill = $this
->prepopulationService
->isDummyDataFillRequested($bookingDto->participants[$index], $bookingDto->getMode())
->isDummyDataFillRequested($bookingCreateDto->participants[$index], $bookingCreateDto->getMode())
;
if (true === $isSubmitted && true === $isDummyDataFill) {
$this->prepopulationService->fillDummyParticipant($bookingDto->participants[$index], $index);
$this->prepopulationService->fillDummyParticipant($bookingCreateDto->participants[$index], $index);
$this->bookingService->preselectDefaultServices($bookingDto);
$this->bookingService->applyCreateBookingStatusRules($bookingDto);
$this->bookingSessionService->saveBookingDto($request, $bookingDto, BookingDto::MODE_CREATE);
$this->bookingService->preselectDefaultServices($bookingCreateDto);
$this->bookingService->applyCreateBookingStatusRules($bookingCreateDto);
$this->bookingSessionService->saveBookingDto($request, $bookingCreateDto, BookingDto::MODE_CREATE);
$form = $this->createParticipantForm($bookingDto, $index);
$form = $this->createParticipantForm($bookingCreateDto, $index);
return $this->renderParticipantForm($form, $index, $bookingDto);
return $this->renderParticipantForm($form, $index, $bookingCreateDto);
}
if (true === $isSubmitted) {
$this->bookingService->preselectDefaultServices($bookingDto);
$this->bookingService->applyCreateBookingStatusRules($bookingDto);
$this->bookingService->preselectDefaultServices($bookingCreateDto);
$this->bookingService->applyCreateBookingStatusRules($bookingCreateDto);
}
$notifications = $this->participantFormSupportService->collectAndClearNotifications($bookingDto);
$notifications = $this->participantFormSupportService->collectAndClearNotifications($bookingCreateDto);
if (true === $isSubmitted && true === $form->isValid()) {
$this->bookingSessionService->saveBookingDto($request, $bookingDto, BookingDto::MODE_CREATE);
$this->bookingSessionService->saveBookingDto($request, $bookingCreateDto, BookingDto::MODE_CREATE);
$this->addNotificationsAsFlashMessages($notifications);
return $this->redirectToRoute('app_booking_create_step_2');
}
return $this->renderParticipantForm($form, $index, $bookingDto);
return $this->renderParticipantForm($form, $index, $bookingCreateDto);
}
/**
@@ -114,7 +116,11 @@ class Step2ParticipantController extends AbstractController
$this->participantFormSupportService->ensureParticipantExists($bookingDto, $index);
$this->travelDataService->enrichWithFreshAvailabilities($bookingDto->travel);
if ($redirect = $this->redirectIfRoomSelectionsStale($request, $bookingDto, $this->bookingSessionService)) {
return $redirect;
}
$this->bookingService->updateBookingStatusFromRoomSelection($bookingDto);
return $this->handleParticipantRefresh(
$request,