wip: confirmation step

This commit is contained in:
Björn Fromme
2026-03-16 11:59:10 +01:00
parent 3f7db4e772
commit ee264e88d4
5 changed files with 277 additions and 4 deletions
@@ -41,6 +41,7 @@ trait BookingCreateTrait
$route = match ($bookingCreateDto->currentStep) {
2 => 'app_booking_create_step_2',
3 => 'app_booking_create_step_3',
4 => 'app_booking_create_step_4',
default => 'app_booking_create_step_1',
};
@@ -49,12 +49,10 @@ class CreateStep3Controller extends AbstractController
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$bookingCreateDto->currentStep = 4;
$this->bookingService->saveBookingCreateDto($request, $bookingCreateDto);
// TODO: Redirect to confirmation page or direct API submission
$this->addFlash('success', 'Zahlungsart erfolgreich ausgewählt.');
return $this->redirectToRoute('app_booking_create_step_3');
return $this->redirectToRoute('app_booking_create_step_4');
}
return $this->render('booking/create_step_3.html.twig', [
@@ -0,0 +1,64 @@
<?php
declare(strict_types=1);
namespace App\Controller\Booking;
use App\Controller\Traits\HtmxControllerTrait;
use App\Form\BookingCreateStep4Type;
use App\Service\BookingService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
/**
* Handles the fourth step of the booking creation process (confirmation).
*/
class CreateStep4Controller extends AbstractController
{
use BookingCreateTrait;
use BookingExceptionHandlerTrait;
use HtmxControllerTrait;
public function __construct(
private readonly BookingService $bookingService,
) {
}
/**
* Displays booking summary and confirmation form.
*/
#[Route('/bookings/create/confirmation', name: 'app_booking_create_step_4')]
public function step4(Request $request): Response
{
$result = $this->getOrCreateBookingCreateDto($this->bookingService, $request);
if ($result instanceof Response) {
return $result;
}
$bookingCreateDto = $result;
// Validate step access
if ($redirect = $this->validateStepAccess($bookingCreateDto, 4)) {
return $redirect;
}
$form = $this->createForm(BookingCreateStep4Type::class, $bookingCreateDto);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
// TODO: Perform inquiry API call
// TODO: If inquiry successful, perform booking API call
// TODO: Clear session and redirect to success page
$this->addFlash('success', 'Buchung erfolgreich abgeschlossen.');
return $this->redirectToRoute('app_booking_create_step_4');
}
return $this->render('booking/create_step_4.html.twig', [
'bookingCreateDto' => $bookingCreateDto,
'form' => $form->createView(),
...$this->getSummaryVariables($bookingCreateDto),
]);
}
}
+37
View File
@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace App\Form;
use App\Form\Model\BookingCreateDto;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints as Assert;
class BookingCreateStep4Type extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('confirmationAccepted', CheckboxType::class, [
'label' => 'Ich bestätige, dass alle Angaben korrekt sind und möchte verbindlich buchen.',
'mapped' => false,
'constraints' => [
new Assert\IsTrue(
message: 'Bitte bestätigen Sie Ihre Buchung.'
),
],
])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => BookingCreateDto::class,
]);
}
}