diff --git a/src/BusProNet/ApiClient.php b/src/BusProNet/ApiClient.php index 446603d..9b5013d 100644 --- a/src/BusProNet/ApiClient.php +++ b/src/BusProNet/ApiClient.php @@ -90,14 +90,7 @@ class ApiClient 'key' => $this->createKey($this->config['bpn_username'], $this->config['bpn_password'], static::TYPE_CUSTOMER_DATA), 'satz' => ['@typ' => static::TYPE_CUSTOMER_DATA], 'art' => 'Adresse_Neu', - 'adressdaten' => [ - 'geschlecht' => $registrationData->gender, - 'vorname' => $registrationData->firstName, - 'name' => $registrationData->name, - 'kommunikation' => [ - 'email' => $registrationData->email, - ], - ], + 'adressdaten' => $registrationData->toPayload(), ]; return $this->sendRequest(static::TYPE_CUSTOMER_DATA, $data); diff --git a/src/Controller/RegistrationController.php b/src/Controller/RegistrationController.php index 6c545ce..fa8b3c0 100644 --- a/src/Controller/RegistrationController.php +++ b/src/Controller/RegistrationController.php @@ -41,12 +41,12 @@ class RegistrationController extends AbstractController $this->addFlash('success', 'Du erhältst in Kürze eine E-Mail mit einem Link zum (Zurück)setzen deines Passworts.'); } $this->logger->info('Initiated registration', [ - 'email' => $registrationData->email, + 'email' => $registrationData->communication->email, ]); } catch (ApiClientException $e) { $this->addFlash('error', $e->getMessage()); $this->logger->error('Error initiating registration', [ - 'email' => $registrationData->email, + 'email' => $registrationData->communication->email, 'error' => $e->getMessage(), ]); } diff --git a/src/Form/Model/RegistrationDto.php b/src/Form/Model/RegistrationDto.php index d714d36..5067440 100644 --- a/src/Form/Model/RegistrationDto.php +++ b/src/Form/Model/RegistrationDto.php @@ -1,7 +1,11 @@ address = new Address(); + $this->communication = new Communication(); + } + + /** + * Converts the registration data to API payload format. + * + * @return array + */ + public function toPayload(): array + { + return [ + 'geschlecht' => $this->gender, + 'vorname' => $this->firstName, + 'name' => $this->name, + 'nationalitaet' => $this->nationality, + 'geburtsdatum' => $this->dateOfBirth?->format('d.m.Y'), + 'anschrift' => $this->address->toPayload(), + 'kommunikation' => $this->communication->toPayload(), + ]; + } } diff --git a/src/Form/RegistrationType.php b/src/Form/RegistrationType.php index 42bf260..3ced087 100644 --- a/src/Form/RegistrationType.php +++ b/src/Form/RegistrationType.php @@ -1,11 +1,11 @@ add('gender', ChoiceType::class, [ - 'label' => 'Gender', - 'choices' => [ - 'männlich' => 'M', - 'weiblich' => 'W', - 'divers' => 'D', - ], - ]) ->add('firstName', TextType::class, [ - 'label' => 'Name', + 'label' => 'Vorname', 'sanitize_html' => true, ]) ->add('name', TextType::class, [ 'label' => 'Nachname', 'sanitize_html' => true, ]) - ->add('email', EmailType::class, [ - 'label' => 'E-Mail', + ->add('personalData', PersonalDataType::class, [ + 'label' => false, + 'inherit_data' => true, ]) ; } @@ -41,6 +34,7 @@ class RegistrationType extends AbstractType { $resolver->setDefaults([ 'data_class' => RegistrationDto::class, + 'validation_groups' => ['Default', 'personal_data'], ]); } } diff --git a/templates/registration/index.html.twig b/templates/registration/index.html.twig index ea9ed38..99d9161 100644 --- a/templates/registration/index.html.twig +++ b/templates/registration/index.html.twig @@ -1,30 +1,50 @@ {% extends 'layout.html.twig' %} {% block content %} -
-
-

- Registrierung -
- MyE&P -

- {% include '_partials/_flashes.html.twig' %} -
- {{ form_start(form) }} +
+

+ Registrierung +
+ MyE&P +

+ {% include '_partials/_flashes.html.twig' %} + {{ form_start(form) }} +
+
+

+ Persönliches +

+ {{ form_row(form.personalData.gender, { 'label_attr': { 'class': 'text-white' } }) }} {{ form_row(form.firstName, { 'label_attr': { 'class': 'text-white' } }) }} {{ form_row(form.name, { 'label_attr': { 'class': 'text-white' } }) }} - {{ form_row(form.email, { 'label_attr': { 'class': 'text-white' } }) }} - {{ form_row(form.gender, { 'label_attr': { 'class': 'text-white' } }) }} - - {{ form_rest(form) }} - {{ form_end(form) }} + {{ form_row(form.personalData.dateOfBirth, { 'label_attr': { 'class': 'text-white' } }) }} + {{ form_row(form.personalData.nationality, { 'label_attr': { 'class': 'text-white' } }) }} +

+ Kontakt +

+ {{ form_row(form.personalData.email, { 'label_attr': { 'class': 'text-white' } }) }} + {{ form_row(form.personalData.mobile, { 'label_attr': { 'class': 'text-white' } }) }} + {{ form_row(form.personalData.phone, { 'label_attr': { 'class': 'text-white' } }) }}
- +
+

+ Anschrift +

+ {{ form_row(form.personalData.street, { 'label_attr': { 'class': 'text-white' } }) }} + {{ form_row(form.personalData.postCode, { 'label_attr': { 'class': 'text-white' } }) }} + {{ form_row(form.personalData.city, { 'label_attr': { 'class': 'text-white' } }) }} + {{ form_row(form.personalData.country, { 'label_attr': { 'class': 'text-white' } }) }} +
+
+
+ Zum Login +
+ {{ form_rest(form) }} + {{ form_end(form) }}
{% endblock %}