wip: booking summary for step 1
This commit is contained in:
@@ -33,7 +33,7 @@ class CreateStep1Controller extends AbstractController
|
||||
public function index(Request $request): Response
|
||||
{
|
||||
$bookingCreateDto = $this->bookingService->getOrCreateBookingCreateDto($request);
|
||||
$participantsCount = $this->bookingService->getParticipantsCount($bookingCreateDto->roomSelections, $bookingCreateDto->travel);
|
||||
$summary = $this->bookingService->getRoomSummaryAndParticipantCount($bookingCreateDto);
|
||||
|
||||
// Validate step access - allow step 1 or redirect to current step
|
||||
$this->validateStepAccess($bookingCreateDto, 1);
|
||||
@@ -53,8 +53,33 @@ class CreateStep1Controller extends AbstractController
|
||||
|
||||
return $this->render('booking/create_step_1.html.twig', [
|
||||
'bookingCreateDto' => $bookingCreateDto,
|
||||
'participantsCount' => $participantsCount,
|
||||
'roomSummary' => $summary['selectedRooms'],
|
||||
'participantCount' => $summary['participantCount'],
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* HTMX endpoint for live summary updates in step 1.
|
||||
*/
|
||||
#[Route('/bookings/create/room-summary', name: 'app_booking_create_step_1_room_summary', methods: ['POST'])]
|
||||
public function roomSummary(Request $request): Response
|
||||
{
|
||||
$bookingCreateDto = $this->bookingService->getOrCreateBookingCreateDto($request);
|
||||
|
||||
// Process the form to update the DTO with the latest room selection
|
||||
$form = $this->createForm(BookingCreateStep1Type::class, $bookingCreateDto, [
|
||||
'validation_groups' => false,
|
||||
]);
|
||||
$form->handleRequest($request);
|
||||
|
||||
$this->bookingService->saveBookingCreateDto($request, $bookingCreateDto);
|
||||
|
||||
$summary = $this->bookingService->getRoomSummaryAndParticipantCount($bookingCreateDto);
|
||||
|
||||
return $this->render('booking/_room_summary.html.twig', [
|
||||
'roomSummary' => $summary['selectedRooms'],
|
||||
'participantCount' => $summary['participantCount'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,4 +120,21 @@ class BookingService
|
||||
|
||||
return $counts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a summary of selected rooms and the resulting participant count for a booking.
|
||||
*
|
||||
* @param BookingCreateDto $bookingCreateDto
|
||||
* @return array{selectedRooms: array, participantCount: int}
|
||||
*/
|
||||
public function getRoomSummaryAndParticipantCount(BookingCreateDto $bookingCreateDto): array
|
||||
{
|
||||
$selectedRooms = $bookingCreateDto->getSelectedRooms();
|
||||
$participantCount = $this->getParticipantsCount($selectedRooms, $bookingCreateDto->travel);
|
||||
|
||||
return [
|
||||
'selectedRooms' => $selectedRooms,
|
||||
'participantCount' => $participantCount,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<div id="booking-summary">
|
||||
<h3>Zusammenfassung</h3>
|
||||
<h4>Zimmer</h4>
|
||||
<ul class="list-disc list-inside pb-4">
|
||||
{% for roomSelection in roomSummary %}
|
||||
<li>
|
||||
{{ roomSelection.quantity }} x {{ roomSelection.roomLabel }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<h4>Anzahl Teilnehmer</h4>
|
||||
<p>
|
||||
{{ participantCount }}
|
||||
</p>
|
||||
</div>
|
||||
@@ -7,7 +7,18 @@
|
||||
<div class="col-span-2">
|
||||
<h2>Zimmerauswahl</h2>
|
||||
{{ form_start(form) }}
|
||||
{{ form_row(form.roomSelections) }}
|
||||
<div>
|
||||
{% for roomSelection in form.roomSelections %}
|
||||
{{ form_row(roomSelection, {
|
||||
'attr': {
|
||||
'hx-post': path('app_booking_create_step_1_room_summary'),
|
||||
'hx-target': '#booking-summary',
|
||||
'hx-swap': 'outerHTML',
|
||||
'hx-trigger': 'change'
|
||||
}
|
||||
}) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="flex justify-end">
|
||||
<button type="submit" class="button bg-button bg-button--secondary">Weiter</button>
|
||||
</div>
|
||||
@@ -15,13 +26,7 @@
|
||||
{{ form_end(form) }}
|
||||
</div>
|
||||
<div>
|
||||
<h3>Zusammenfassung</h3>
|
||||
<p>Reise: {{ bookingCreateDto.travel.label }}</p>
|
||||
<p>Datum: {{ bookingCreateDto.travel.dateFrom | date('d.m.Y') }} - {{ bookingCreateDto.travel.dateTo | date('d.m.Y') }}</p>
|
||||
<p>Hotel: {{ bookingCreateDto.travel.hotel.name }}</p>
|
||||
{% if participantsCount > 0 %}
|
||||
<p>Teilnehmerzahl: {{ participantsCount }}</p>
|
||||
{% endif %}
|
||||
{% include 'booking/_room_summary.html.twig' %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user