wip: form refactoring
This commit is contained in:
1 parent
65a33922cf
commit
d719b17aec
13 files changed
+158
-100
No files matched your search
@@ -23,8 +23,7 @@ class CreateStep1Controller extends AbstractController
|
||||
|
||||
public function __construct(
|
||||
private readonly BookingService $bookingService,
|
||||
)
|
||||
{
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -34,6 +33,10 @@ class CreateStep1Controller extends AbstractController
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$bookingCreateDto = $this->bookingService->getOrCreateBookingCreateDto($request);
|
||||
|
||||
// Capture the current room selection state before form processing
|
||||
$oldRoomSelectionSnapshot = $this->bookingService->createRoomSelectionSnapshot($bookingCreateDto);
|
||||
|
||||
$summary = $this->bookingService->getRoomSummaryAndParticipantCount($bookingCreateDto);
|
||||
|
||||
// Validate step access - allow step 1 or redirect to current step
|
||||
@@ -46,6 +49,9 @@ class CreateStep1Controller extends AbstractController
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
if ($this->bookingService->hasRoomSelectionChanged($oldRoomSelectionSnapshot, $bookingCreateDto)) {
|
||||
$this->bookingService->resetParticipantAssignments($bookingCreateDto);
|
||||
}
|
||||
$bookingCreateDto->currentStep = 2;
|
||||
$this->bookingService->saveBookingCreateDto($request, $bookingCreateDto);
|
||||
|
||||
@@ -80,8 +86,6 @@ class CreateStep1Controller extends AbstractController
|
||||
]);
|
||||
$form->handleRequest($request);
|
||||
|
||||
$this->bookingService->saveBookingCreateDto($request, $bookingCreateDto);
|
||||
|
||||
$summary = $this->bookingService->getRoomSummaryAndParticipantCount($bookingCreateDto);
|
||||
$availableRooms = $bookingCreateDto->travel->getAvailableRooms();
|
||||
$groupedSelectedRooms = $this->bookingService->groupRoomSelectionsByType($summary['selectedRooms'], $availableRooms);
|
||||
|
||||
Reference in new issue
Block a user