From eee7be0c1e89ee9f2c9f5a2eb83b69f646168915 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Sat, 25 Oct 2025 14:09:19 +0200 Subject: [PATCH] feat: gravatar integration --- assets/controllers/gravatar_controller.js | 17 +++++++ src/Service/ParticipantCardDataService.php | 12 +++-- src/Twig/GravatarExtension.php | 28 ++++++++++++ templates/booking/_participant_card.html.twig | 44 ++++++++++++------- templates/booking/_participant_form.html.twig | 13 +++++- 5 files changed, 94 insertions(+), 20 deletions(-) create mode 100644 assets/controllers/gravatar_controller.js create mode 100644 src/Twig/GravatarExtension.php diff --git a/assets/controllers/gravatar_controller.js b/assets/controllers/gravatar_controller.js new file mode 100644 index 0000000..3f67814 --- /dev/null +++ b/assets/controllers/gravatar_controller.js @@ -0,0 +1,17 @@ +import {Controller} from '@hotwired/stimulus' + +export default class extends Controller { + static values = {url: String, alt: String} + static classes = ['image'] + + connect() { + const img = new Image() + img.onload = () => { + img.classList.add(...this.imageClasses) + this.element.innerHTML = '' + this.element.appendChild(img) + } + img.alt = this.altValue + img.src = this.urlValue + } +} diff --git a/src/Service/ParticipantCardDataService.php b/src/Service/ParticipantCardDataService.php index 637f95d..c2804f6 100644 --- a/src/Service/ParticipantCardDataService.php +++ b/src/Service/ParticipantCardDataService.php @@ -25,7 +25,7 @@ class ParticipantCardDataService /** * Get card data for a single participant. * - * @return array{name: string, roomName: string, price: string, isCanceled: bool} + * @return array{name: string, email: string, roomName: string, price: string, isCanceled: bool} */ public function getCardData(BookingDto $bookingDto, int $index): array { @@ -38,6 +38,9 @@ class ParticipantCardDataService // Extract participant name with fallback $name = $this->getParticipantName($participant, $index); + // Extract email + $email = $participant->email ?? ''; + // Extract room name $roomName = $this->getRoomName($bookingDto, $participant); @@ -49,6 +52,7 @@ class ParticipantCardDataService return [ 'name' => $name, + 'email' => $email, 'roomName' => $roomName, 'price' => $price, 'isCanceled' => $isCanceled, @@ -58,7 +62,7 @@ class ParticipantCardDataService /** * Get card data for all participants. * - * @return array + * @return array */ public function getAllCardsData(BookingDto $bookingDto): array { @@ -132,7 +136,7 @@ class ParticipantCardDataService /** * Get card data for a single participant with validation state. * - * @return array{name: string, roomName: string, price: string, isCanceled: bool, isValid: bool, errorMessages: array} + * @return array{name: string, email: string, roomName: string, price: string, isCanceled: bool, isValid: bool, errorMessages: array} */ public function getCardDataWithValidation(BookingDto $bookingDto, int $index, array $validationGroups): array { @@ -171,7 +175,7 @@ class ParticipantCardDataService /** * Get card data for all participants with validation state. * - * @return array}> + * @return array}> */ public function getAllCardsDataWithValidation(BookingDto $bookingDto, array $validationGroups): array { diff --git a/src/Twig/GravatarExtension.php b/src/Twig/GravatarExtension.php new file mode 100644 index 0000000..aaa46f8 --- /dev/null +++ b/src/Twig/GravatarExtension.php @@ -0,0 +1,28 @@ +
-
-

- {{ cardData.name }} -

- {% if isCanceled %} - - storniert - - {% endif %} - {% if not isValid %} - - unvollständige oder fehlerhafte Daten - - {% endif %} +
+
+ {{ icon('user', 'w-12 h-12 text-gray-400') }} +
+
+
+

+ {{ cardData.name }} +

+ {% if isCanceled %} + + storniert + + {% endif %} + {% if not isValid %} + + unvollständige oder fehlerhafte Daten + + {% endif %} +
+

{{ cardData.roomName }}

+
-

{{ cardData.roomName }}

{{ cardData.price }} diff --git a/templates/booking/_participant_form.html.twig b/templates/booking/_participant_form.html.twig index 20811db..075b2db 100644 --- a/templates/booking/_participant_form.html.twig +++ b/templates/booking/_participant_form.html.twig @@ -45,7 +45,18 @@ {% block participant_form %} {% import _self as macros %}
-

{{ participantIndex == 0 ? 'Anmelder:in' : 'Teilnehmer:in ' ~ (participantIndex + 1) }}

+
+
+ {{ icon('user', 'w-16 h-16 text-gray-400') }} +
+

{{ participantIndex == 0 ? 'Anmelder:in' : 'Teilnehmer:in ' ~ (participantIndex + 1) }}

+
{{ form_start(form, { 'attr': {