feat: improved promotional and purchase vouchers

This commit is contained in:
Björn Fromme
2026-03-16 11:59:11 +01:00
parent 7df99521c4
commit fb983f23dd
15 changed files with 357 additions and 137 deletions
+25 -12
View File
@@ -267,10 +267,20 @@ class IndexController extends AbstractController
$form->handleRequest($request);
// Collect notifications from field handlers (run during PRE_SUBMIT)
$notifications = $this->collectAndClearNotifications($bookingDto);
if ($form->isSubmitted() && $form->isValid()) {
// Save updated booking data to session
$this->bookingService->saveBookingDto($request, $bookingDto, BookingDto::MODE_EDIT);
// Add notifications as flash messages (redirects destroy HTMX-triggered toasts)
if (false === empty($notifications)) {
foreach ($notifications as $notification) {
$this->addFlash($notification['type'], $notification['message']);
}
}
// Redirect back to cards
return $this->hxRedirect($request, $this->generateUrl('app_booking_edit', ['id' => $id]));
}
@@ -300,12 +310,21 @@ class IndexController extends AbstractController
// HTMX request: render blocks only with OOB swap
if ($this->isHxRequest($request)) {
return $this->htmxOobResponse(
$response = $this->htmxOobResponse(
'booking/_participant_form.html.twig',
['participant_form', 'booking_summary'],
$templateData,
$this->generateUrl('app_booking_edit_participant', ['id' => $id, 'index' => $index])
);
// Add notifications to render response if present
if (false === empty($notifications)) {
$response->headers->set('HX-Trigger', json_encode([
'showNotifications' => $notifications,
]));
}
return $response;
}
// Regular request: render full template
@@ -362,18 +381,12 @@ class IndexController extends AbstractController
$form->handleRequest($request);
// Collect notifications from field handlers
$notifications = $this->collectAndClearNotifications($bookingDto);
// Save updated booking data to session
$this->bookingService->saveBookingDto($request, $bookingDto, BookingDto::MODE_EDIT);
// Collect notifications from participant DTO
$participant = $bookingDto->participants[$index] ?? null;
$notifications = $participant?->notifications ?? [];
// Clear notifications after collecting
if (null !== $participant) {
$participant->notifications = [];
}
// Get complete summary data (pricing, rooms, CMS data)
$summaryData = $this->summaryDataService->getSummaryData($bookingDto);
@@ -400,9 +413,9 @@ class IndexController extends AbstractController
);
// Add notifications to HX-Trigger header if present
if ([] !== $notifications) {
if (false === empty($notifications)) {
$response->headers->set('HX-Trigger', json_encode([
'showNotifications' => ['notifications' => $notifications],
'showNotifications' => $notifications,
]));
}