feat: authenticated booking
This commit is contained in:
@@ -15,6 +15,7 @@ use App\Htmx\HxTrait;
|
||||
use App\Service\BookingPriceCalculatorService;
|
||||
use App\Service\BookingService;
|
||||
use App\Service\ParticipantCardDataService;
|
||||
use App\Service\ParticipantPrepopulationService;
|
||||
use App\Service\RoomAssignmentService;
|
||||
use App\Service\TravelDataService;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
@@ -42,6 +43,7 @@ class Step2Controller extends AbstractController
|
||||
private readonly RoomAssignmentService $roomAssignmentService,
|
||||
private readonly ParticipantCardDataService $participantCardService,
|
||||
private readonly ParticipantFieldOptionsProvider $fieldOptionsProvider,
|
||||
private readonly ParticipantPrepopulationService $prepopulationService,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -227,10 +229,29 @@ class Step2Controller extends AbstractController
|
||||
for ($i = 0; $i < $participantsCount; ++$i) {
|
||||
$participant = $participants[$i] ?? new ParticipantDto();
|
||||
$participant->index = $i;
|
||||
|
||||
// Prepopulate applicant from authenticated user (index 0 only)
|
||||
if (0 === $i && $this->getUser() && $this->shouldPrepopulate($participant)) {
|
||||
$participant = $this->prepopulationService->prepopulateApplicantFromUser(
|
||||
$this->getUser(),
|
||||
$participant
|
||||
);
|
||||
}
|
||||
|
||||
$bookingCreateDto->participants[$i] = $participant;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a participant should be prepopulated.
|
||||
*
|
||||
* Only prepopulates if the participant is "fresh" (no name set yet).
|
||||
*/
|
||||
private function shouldPrepopulate(ParticipantDto $participant): bool
|
||||
{
|
||||
return null === $participant->firstName || '' === $participant->firstName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enriches travel data with cached availability information from BusProNet API.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user