feat: fetch additional content from cms via api
This commit is contained in:
1 parent
33c3dc6022
commit
26681e5c62
18 files changed
+107
-124
No files matched your search
@@ -76,52 +76,6 @@ trait ParticipantCardFlowTrait
|
||||
return $this->createForm(BookingParticipantType::class, $wrapper, $formOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate summary data (pricing, room counts, etc.).
|
||||
*
|
||||
* @return array{
|
||||
* participantsCount: int,
|
||||
* totalPrice: string,
|
||||
* groupedSelectedRooms: array,
|
||||
* assignmentCounts: array
|
||||
* }
|
||||
*/
|
||||
private function calculateSummaryData(BookingDto $bookingDto): array
|
||||
{
|
||||
// Calculate individual prices for all participants
|
||||
$participantPrices = $this->priceCalculator->calculateAllParticipantIndividualPrices($bookingDto);
|
||||
|
||||
// Calculate total price
|
||||
$totalPrice = array_sum($participantPrices);
|
||||
|
||||
// Get room assignment counts
|
||||
$roomCounts = [];
|
||||
foreach ($bookingDto->participants as $participant) {
|
||||
if (null !== $participant->assignedRoomId) {
|
||||
$roomCounts[$participant->assignedRoomId] = ($roomCounts[$participant->assignedRoomId] ?? 0) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Group selected rooms with counts
|
||||
$groupedSelectedRooms = [];
|
||||
foreach ($roomCounts as $roomId => $count) {
|
||||
$room = $bookingDto->travel->getRoomById($roomId);
|
||||
if (null !== $room) {
|
||||
$groupedSelectedRooms[] = [
|
||||
'room' => $room,
|
||||
'count' => $count,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'participantsCount' => count($bookingDto->participants),
|
||||
'totalPrice' => number_format($totalPrice, 2, ',', '.').' €',
|
||||
'groupedSelectedRooms' => $groupedSelectedRooms,
|
||||
'assignmentCounts' => $roomCounts,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Process single participant form refresh.
|
||||
*
|
||||
@@ -155,11 +109,8 @@ trait ParticipantCardFlowTrait
|
||||
// Save updated booking data to session (after collecting & clearing notifications)
|
||||
$this->bookingService->saveBookingDto($request, $bookingDto, $bookingDto->getMode());
|
||||
|
||||
// Calculate summary data for sidebar
|
||||
$summaryData = $this->calculateSummaryData($bookingDto);
|
||||
|
||||
// Get detailed pricing data for summary sidebar
|
||||
$summary = $this->bookingService->getRoomSummaryAndParticipantCount($bookingDto);
|
||||
// Get complete summary data (pricing, rooms, CMS data)
|
||||
$summaryData = $this->summaryDataService->getSummaryData($bookingDto);
|
||||
|
||||
// Render form and sidebar with OOB swap using htmxOobResponse
|
||||
// This renders ONLY the specific blocks, not the entire template
|
||||
@@ -171,7 +122,8 @@ trait ParticipantCardFlowTrait
|
||||
'participantIndex' => $index,
|
||||
'bookingDto' => $bookingDto,
|
||||
'summaryData' => $summaryData,
|
||||
'pricingData' => $summary['pricing'],
|
||||
'pricingData' => $summaryData['pricingData'],
|
||||
'cmsData' => $summaryData['cmsData'],
|
||||
'refreshRouteName' => $refreshRouteName,
|
||||
'submitRouteName' => $submitRouteName,
|
||||
]
|
||||
@@ -193,7 +145,7 @@ trait ParticipantCardFlowTrait
|
||||
* Controllers using this trait must have the following properties:
|
||||
* - BookingService $bookingService
|
||||
* - ParticipantCardDataService $participantCardService
|
||||
* - BookingPriceCalculatorService $priceCalculator
|
||||
* - BookingSummaryDataService $summaryDataService
|
||||
*/
|
||||
abstract private function createForm(string $type, $data = null, array $options = []): FormInterface;
|
||||
|
||||
|
||||
Reference in new issue
Block a user