feat: inform user about automatic reassignments or reset selections
This commit is contained in:
@@ -77,6 +77,11 @@ class ParticipantDto
|
||||
// Bulk insurance booking flag (applicant only: when checked, assigns same insurance type to all participants)
|
||||
public bool $bulkInsuranceBooking = false;
|
||||
|
||||
/**
|
||||
* @var array<array{type: string, message: string}> Notification messages for user feedback
|
||||
*/
|
||||
public array $notifications = [];
|
||||
|
||||
public static function fromPersonalData(PersonalData $personalData): static
|
||||
{
|
||||
$instance = new static();
|
||||
@@ -164,4 +169,18 @@ class ParticipantDto
|
||||
{
|
||||
return $this->insurance?->price ?? 0.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a notification message for user feedback.
|
||||
*
|
||||
* @param string $type The notification type (info, warning, success)
|
||||
* @param string $message The notification message
|
||||
*/
|
||||
public function addNotification(string $type, string $message): void
|
||||
{
|
||||
$this->notifications[] = [
|
||||
'type' => $type,
|
||||
'message' => $message,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,6 +151,13 @@ class ParticipantInsuranceFieldHandler extends AbstractParticipantFieldHandler
|
||||
$bookingDto
|
||||
);
|
||||
$participant->insurance = $reassignedInsurance;
|
||||
|
||||
if (null !== $reassignedInsurance) {
|
||||
$participant->addNotification(
|
||||
'info',
|
||||
sprintf('Versicherung automatisch angepasst: %s', $reassignedInsurance->label)
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Insurance not found - clear selection
|
||||
@@ -174,6 +181,14 @@ class ParticipantInsuranceFieldHandler extends AbstractParticipantFieldHandler
|
||||
$participant,
|
||||
$bookingDto
|
||||
);
|
||||
|
||||
if (null !== $reassignedInsurance && $reassignedInsurance->id !== $currentInsurance->id) {
|
||||
$participant->addNotification(
|
||||
'info',
|
||||
sprintf('Versicherung automatisch angepasst an neuen Preis: %s', $reassignedInsurance->label)
|
||||
);
|
||||
}
|
||||
|
||||
$participant->insurance = $reassignedInsurance; // null if no suitable match found
|
||||
}
|
||||
|
||||
|
||||
@@ -64,9 +64,18 @@ class ParticipantRentalsFieldHandler extends AbstractParticipantFieldHandler
|
||||
return;
|
||||
}
|
||||
|
||||
// Store previous rental state BEFORE checking skipass
|
||||
$previousRentals = $participant->rentals;
|
||||
|
||||
// Check if rentals should be available based on skipass selection
|
||||
if (null === $participant->skiPass) {
|
||||
// No skipass selected = clear all rental selections
|
||||
if ([] !== $previousRentals) {
|
||||
$participant->addNotification(
|
||||
'warning',
|
||||
'Ausrüstung wurde entfernt (kein Skipass ausgewählt)'
|
||||
);
|
||||
}
|
||||
$participant->rentals = [];
|
||||
|
||||
return;
|
||||
@@ -85,6 +94,14 @@ class ParticipantRentalsFieldHandler extends AbstractParticipantFieldHandler
|
||||
$participantIndex
|
||||
);
|
||||
|
||||
// Notify if rentals were cleared due to skipass duration change
|
||||
if ([] !== $previousRentals && [] === $validSelections) {
|
||||
$participant->addNotification(
|
||||
'warning',
|
||||
'Ausrüstung wurde entfernt (andere Skipass-Dauer ausgewählt)'
|
||||
);
|
||||
}
|
||||
|
||||
$participant->rentals = $validSelections;
|
||||
}
|
||||
|
||||
@@ -168,7 +185,7 @@ class ParticipantRentalsFieldHandler extends AbstractParticipantFieldHandler
|
||||
* - rental.dateFrom === skipass.dateFrom
|
||||
* - rental.dateTo === skipass.dateTo
|
||||
*
|
||||
* @param array $rentals All available rental services
|
||||
* @param array $rentals All available rental services
|
||||
* @param \App\Form\Model\ParticipantDto $participant The participant with skipass selection
|
||||
*
|
||||
* @return array Filtered rentals matching the skipass duration
|
||||
|
||||
Reference in New Issue
Block a user