feat: mark unavailable services as read-only and add tooltip

This commit is contained in:
Björn Fromme
2026-03-16 11:59:10 +01:00
parent ead448b8d4
commit 0d1ef6d40e
2 changed files with 124 additions and 49 deletions
+19 -4
View File
@@ -74,19 +74,34 @@ class ServiceAvailabilityCalculator
}
/**
* Check if a specific service is available for the current participant.
* Check if a specific service is unavailable (sold out) for the current participant.
*
* @param int $serviceId The ID of the service to check
* @param BookingCreateDto $bookingDto The booking data with participant selections
* @param int $participantIndex The index of the participant currently filling the form
*
* @return bool True if the service has remaining availability
* @return bool True if the service is unavailable (has availability limit and remaining is 0)
*/
public function isServiceAvailable(int $serviceId, BookingCreateDto $bookingDto, int $participantIndex): bool
public function isServiceUnavailable(int $serviceId, BookingCreateDto $bookingDto, int $participantIndex): bool
{
$allServices = $this->getAllServicesFromTravel($bookingDto);
$service = null;
foreach ($allServices as $serviceObj) {
if ($serviceObj->id === $serviceId) {
$service = $serviceObj;
break;
}
}
// If service not found or has no availability limit, it's not unavailable
if (null === $service || null === $service->available || $service->available <= 0) {
return false;
}
$remainingAvailability = $this->calculateRemainingAvailability($bookingDto, $participantIndex);
return ($remainingAvailability[$serviceId] ?? 0) > 0;
return ($remainingAvailability[$serviceId] ?? $service->available) <= 0;
}
/**