wip: feedback about booked and assigned rooms

This commit is contained in:
Björn Fromme
2025-07-23 11:39:03 +02:00
parent e8c27cb51b
commit 8746397d83
4 changed files with 126 additions and 46 deletions
@@ -4,11 +4,11 @@ declare(strict_types=1);
namespace App\Controller\Booking;
use App\Controller\Traits\HtmxControllerTrait;
use App\Form\BookingCreateStep2Type;
use App\Form\Model\BookingCreateDto;
use App\Form\Model\ParticipantDto;
use App\Service\BookingService;
use App\Validator\Constraints\Participant;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -23,6 +23,7 @@ use Symfony\Component\Routing\Attribute\Route;
class CreateStep2Controller extends AbstractController
{
use BookingCreateTrait;
use HtmxControllerTrait;
public function __construct(
private readonly BookingService $bookingService,
@@ -61,9 +62,12 @@ class CreateStep2Controller extends AbstractController
return $this->redirectToRoute('app_booking_create_step_3');
}
$roomAssignmentCounts = $this->bookingService->getRoomAssignmentCounts($bookingCreateDto);
return $this->render('booking/create_step_2.html.twig', [
'bookingCreateDto' => $bookingCreateDto,
'participantsCount' => $participantsCount,
'assignmentCounts' => $roomAssignmentCounts,
'form' => $form->createView(),
]);
}
@@ -76,6 +80,7 @@ class CreateStep2Controller extends AbstractController
public function refreshParticipantForm(Request $request): Response
{
$bookingCreateDto = $this->bookingService->getOrCreateBookingCreateDto($request);
$participantsCount = $this->getParticipantsCount($bookingCreateDto);
// Process form data without validation to capture current state
$form = $this->createForm(BookingCreateStep2Type::class, $bookingCreateDto, [
@@ -85,9 +90,20 @@ class CreateStep2Controller extends AbstractController
$form->handleRequest($request);
return $this->renderBlock('booking/create_step_2.html.twig', 'participants_form', [
'form' => $form->createView(),
]);
$roomAssignmentCounts = $this->bookingService->getRoomAssignmentCounts($bookingCreateDto);
// The DTO is now updated with the latest selection.
// We can now render the blocks with the fresh data.
return $this->htmxOobResponse(
'booking/create_step_2.html.twig',
['participants_form', 'booking_summary'],
[
'form' => $form->createView(),
'bookingCreateDto' => $bookingCreateDto,
'participantsCount' => $participantsCount,
'assignmentCounts' => $roomAssignmentCounts,
]
);
}
private function getParticipantsCount(BookingCreateDto $bookingCreateDto): int