From ad40661594ac47af935b630c6a86056c38f108f1 Mon Sep 17 00:00:00 2001 From: Du Peng Date: Wed, 28 Jun 2023 12:05:02 +0200 Subject: [PATCH 1/4] (bug) cannot save pre registration end date is empty --- app/frontend/src/javascript/components/events/event-form.tsx | 3 +++ app/frontend/src/javascript/controllers/events.js.erb | 3 ++- app/frontend/templates/events/show.html | 1 + config/locales/app.public.en.yml | 1 + config/locales/app.public.fr.yml | 1 + 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/frontend/src/javascript/components/events/event-form.tsx b/app/frontend/src/javascript/components/events/event-form.tsx index 0d8c0b81b..209f17553 100644 --- a/app/frontend/src/javascript/components/events/event-form.tsx +++ b/app/frontend/src/javascript/components/events/event-form.tsx @@ -100,6 +100,9 @@ export const EventForm: React.FC = ({ action, event, onError, on * Callback triggered when the user validates the machine form: handle create or update */ const onSubmit: SubmitHandler = (data: Event) => { + if (data.pre_registration_end_date.toString() === 'Invalid Date') { + data.pre_registration_end_date = null; + } if (action === 'update') { if (event?.recurrence_events?.length > 0) { setUpdatingEvent(data); diff --git a/app/frontend/src/javascript/controllers/events.js.erb b/app/frontend/src/javascript/controllers/events.js.erb index 7b983f7cb..3fbcd3fdf 100644 --- a/app/frontend/src/javascript/controllers/events.js.erb +++ b/app/frontend/src/javascript/controllers/events.js.erb @@ -303,7 +303,8 @@ Application.Controllers.controller('ShowEventController', ['$scope', '$state', ' $scope.now.isBefore($scope.eventEndDateTime) && helpers.isUserValidatedByType($scope.ctrl.member, $scope.settings, 'event'); if ($scope.event.pre_registration) { - return bookable && $scope.event.pre_registration_end_date && $scope.now.isSameOrBefore($scope.event.pre_registration_end_date, 'day'); + const endDate = $scope.event.pre_registration_end_date || $scope.event.end_date + return bookable && $scope.now.isSameOrBefore(endDate, 'day'); } else { return bookable; } diff --git a/app/frontend/templates/events/show.html b/app/frontend/templates/events/show.html index 421ec4aa6..bc6138d30 100644 --- a/app/frontend/templates/events/show.html +++ b/app/frontend/templates/events/show.html @@ -75,6 +75,7 @@
{{ 'app.public.events_show.event_type.nominative' }} {{ 'app.public.events_show.event_type.family' }} + {{ 'app.public.events_show.pre_registration' }}
diff --git a/config/locales/app.public.en.yml b/config/locales/app.public.en.yml index 21c7a0b25..5213b4a30 100644 --- a/config/locales/app.public.en.yml +++ b/config/locales/app.public.en.yml @@ -365,6 +365,7 @@ en: last_name_and_first_name: "Last name and first name" pre_book: "Pre-book" pre_registration_end_date: "Pre-registration end date" + pre_registration: "Pre-registration" #public calendar calendar: calendar: "Calendar" diff --git a/config/locales/app.public.fr.yml b/config/locales/app.public.fr.yml index 580a75f8a..fa31475d7 100644 --- a/config/locales/app.public.fr.yml +++ b/config/locales/app.public.fr.yml @@ -365,6 +365,7 @@ fr: last_name_and_first_name: "Nom et prénom" pre_book: "Pré-réserver" pre_registration_end_date: "Date de fin de pré-réservation" + pre_registration: "Pré-réservation" #public calendar calendar: calendar: "Calendrier" From 25debb41413c30faf3fe9b9dde1ea5d4dc852a9c Mon Sep 17 00:00:00 2001 From: Du Peng Date: Wed, 28 Jun 2023 12:05:15 +0200 Subject: [PATCH 2/4] (feat) add success info after reservation is paid --- app/frontend/src/javascript/controllers/admin/events.js | 3 ++- config/locales/app.admin.en.yml | 1 + config/locales/app.admin.fr.yml | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/frontend/src/javascript/controllers/admin/events.js b/app/frontend/src/javascript/controllers/admin/events.js index ff1162224..ebc30999b 100644 --- a/app/frontend/src/javascript/controllers/admin/events.js +++ b/app/frontend/src/javascript/controllers/admin/events.js @@ -609,10 +609,11 @@ Application.Controllers.controller('ShowEventReservationsController', ['$scope', if (r.id === reservation.id) { return reservation; } + growl.success(_t('app.admin.event_reservations.reservation_was_successfully_paid')); return r; }); }, function () { - $log.info('Pay reservation modal dismissed at: ' + new Date()); + console.log('Pay reservation modal dismissed at: ' + new Date()); }); }; }]); diff --git a/config/locales/app.admin.en.yml b/config/locales/app.admin.en.yml index 4ccba66e0..a7f5ea76c 100644 --- a/config/locales/app.admin.en.yml +++ b/config/locales/app.admin.en.yml @@ -656,6 +656,7 @@ en: confirm_payment_of_html: "{ROLE, select, admin{Cash} other{Pay}}: {AMOUNT}" #(contexte : validate a payment of $20,00) offer_this_reservation: "I offer this reservation" i_have_received_the_payment: "I have received the payment" + reservation_was_successfully_paid: "Reservation was successfully paid." events_settings: title: "Settings" generic_text_block: "Editorial text block" diff --git a/config/locales/app.admin.fr.yml b/config/locales/app.admin.fr.yml index 481d2f497..48787f54b 100644 --- a/config/locales/app.admin.fr.yml +++ b/config/locales/app.admin.fr.yml @@ -656,6 +656,7 @@ fr: confirm_payment_of_html: "{ROLE, select, admin{Encaisser} other{Payer}} : {AMOUNT}" #(contexte : validate a payment of $20,00) offer_this_reservation: "J'offre cette réservation" i_have_received_the_payment: "J'ai reçu le paiement" + reservation_was_successfully_paid: "La réservation a bien été payée." events_settings: title: "Paramètres" generic_text_block: "Bloc de texte rédactionnel" From 9dafc9f22131ba8a386d8ff9c963f4d638233af7 Mon Sep 17 00:00:00 2001 From: Du Peng Date: Wed, 28 Jun 2023 15:33:51 +0200 Subject: [PATCH 3/4] (feat) new pre registration mail and notification --- app/frontend/templates/events/show.html | 4 ++-- app/models/reservation.rb | 24 ++++++++++++++----- ...ember_pre_booked_reservation.json.jbuilder | 5 ++++ ...ember_pre_booked_reservation.json.jbuilder | 3 +++ ...min_member_pre_booked_reservation.html.erb | 19 +++++++++++++++ ...ify_member_pre_booked_reservation.html.erb | 16 +++++++++++++ config/locales/app.public.en.yml | 5 ++-- config/locales/app.public.fr.yml | 9 +++---- config/locales/en.yml | 4 ++++ config/locales/fr.yml | 4 ++++ config/locales/mails.en.yml | 10 ++++++++ config/locales/mails.fr.yml | 10 ++++++++ db/seeds/notification_types.rb | 4 +++- 13 files changed, 102 insertions(+), 15 deletions(-) create mode 100644 app/views/api/notifications/_notify_admin_member_pre_booked_reservation.json.jbuilder create mode 100644 app/views/api/notifications/_notify_member_pre_booked_reservation.json.jbuilder create mode 100644 app/views/notifications_mailer/notify_admin_member_pre_booked_reservation.html.erb create mode 100644 app/views/notifications_mailer/notify_member_pre_booked_reservation.html.erb diff --git a/app/frontend/templates/events/show.html b/app/frontend/templates/events/show.html index bc6138d30..9145c51e0 100644 --- a/app/frontend/templates/events/show.html +++ b/app/frontend/templates/events/show.html @@ -91,7 +91,7 @@
{{ 'app.public.events_show.all_day' }}
{{ 'app.public.events_show.from_time' | translate }} {{event.start_time}} {{ 'app.public.events_show.to_time' | translate }} {{event.end_time}}
{{ 'app.public.events_show.pre_registration_end_date' | translate }}
-
{{ 'app.public.events_show.ending' | translate }} {{event.pre_registration_end_date | amDateFormat:'L'}}
+
{{event.pre_registration_end_date | amDateFormat:'L'}}
@@ -222,7 +222,7 @@ {{ 'app.public.events_show.you_can_find_your_reservation_s_details_on_your_' | translate }} {{ 'app.public.events_show.dashboard' }}
{{ 'app.public.events_show.thank_you_your_pre_registration_has_been_successfully_saved' | translate }}
- {{ 'app.public.events_show.you_can_find_your_reservation_s_details_on_your_' | translate }} {{ 'app.public.events_show.dashboard' }} + {{ 'app.public.events_show.informed_by_email_your_pre_registration' | translate }}
diff --git a/app/models/reservation.rb b/app/models/reservation.rb index 9b9d0ff4f..37a00563d 100644 --- a/app/models/reservation.rb +++ b/app/models/reservation.rb @@ -131,15 +131,27 @@ class Reservation < ApplicationRecord end def notify_member_create_reservation - NotificationCenter.call type: 'notify_member_create_reservation', - receiver: user, - attached_object: self + if reservable_type == 'Event' && reservable.pre_registration? + NotificationCenter.call type: 'notify_member_pre_booked_reservation', + receiver: user, + attached_object: self + else + NotificationCenter.call type: 'notify_member_create_reservation', + receiver: user, + attached_object: self + end end def notify_admin_member_create_reservation - NotificationCenter.call type: 'notify_admin_member_create_reservation', - receiver: User.admins_and_managers, - attached_object: self + if reservable_type == 'Event' && reservable.pre_registration? + NotificationCenter.call type: 'notify_admin_member_pre_booked_reservation', + receiver: User.admins_and_managers, + attached_object: self + else + NotificationCenter.call type: 'notify_admin_member_create_reservation', + receiver: User.admins_and_managers, + attached_object: self + end end def notify_member_limitation_reached diff --git a/app/views/api/notifications/_notify_admin_member_pre_booked_reservation.json.jbuilder b/app/views/api/notifications/_notify_admin_member_pre_booked_reservation.json.jbuilder new file mode 100644 index 000000000..5488d620f --- /dev/null +++ b/app/views/api/notifications/_notify_admin_member_pre_booked_reservation.json.jbuilder @@ -0,0 +1,5 @@ +json.title notification.notification_type +json.description t('.a_RESERVABLE_reservation_was_made_by_USER_html', + RESERVABLE: notification.attached_object.reservable.name, + USER: notification.attached_object.user&.profile&.full_name || t('api.notifications.deleted_user')) + diff --git a/app/views/api/notifications/_notify_member_pre_booked_reservation.json.jbuilder b/app/views/api/notifications/_notify_member_pre_booked_reservation.json.jbuilder new file mode 100644 index 000000000..7e212d607 --- /dev/null +++ b/app/views/api/notifications/_notify_member_pre_booked_reservation.json.jbuilder @@ -0,0 +1,3 @@ +json.title notification.notification_type +json.description t('.your_reservation_RESERVABLE_was_successfully_saved_html', + RESERVABLE: notification.attached_object.reservable.name) diff --git a/app/views/notifications_mailer/notify_admin_member_pre_booked_reservation.html.erb b/app/views/notifications_mailer/notify_admin_member_pre_booked_reservation.html.erb new file mode 100644 index 000000000..46dc4812c --- /dev/null +++ b/app/views/notifications_mailer/notify_admin_member_pre_booked_reservation.html.erb @@ -0,0 +1,19 @@ +<%= render 'notifications_mailer/shared/hello', recipient: @recipient %> + +

+ <%= t('.body.member_reserved_html', + NAME: @attached_object.user&.profile&.full_name || t('api.notifications.deleted_user'), + RESERVABLE: @attached_object.reservable.name) %> +

+

<%= t('.body.reserved_slots') %>

+
    +<% @attached_object.slots.each do |slot| %> + <% if @attached_object.reservable_type == 'Event' %> + <% (slot.start_at.to_date..slot.end_at.to_date).each do |d| %> +
  • <%= "#{I18n.l d, format: :long} #{I18n.l slot.start_at, format: :hour_minute} - #{I18n.l slot.end_at, format: :hour_minute}" %>
  • + <% end %> + <% else %> +
  • <%= "#{I18n.l slot.start_at, format: :long} - #{I18n.l slot.end_at, format: :hour_minute}" %>
  • + <% end %> +<% end %> +
diff --git a/app/views/notifications_mailer/notify_member_pre_booked_reservation.html.erb b/app/views/notifications_mailer/notify_member_pre_booked_reservation.html.erb new file mode 100644 index 000000000..ff507953e --- /dev/null +++ b/app/views/notifications_mailer/notify_member_pre_booked_reservation.html.erb @@ -0,0 +1,16 @@ +<%= render 'notifications_mailer/shared/hello', recipient: @recipient %> + +

<%= t('.body.reservation_saved_html', RESERVATION: @attached_object.reservable.name) %>

+ +

<%= t('.body.your_reserved_slots') %>

+
    +<% @attached_object.slots.each do |slot| %> + <% if @attached_object.reservable_type == 'Event' %> + <% (slot.start_at.to_date..slot.end_at.to_date).each do |d| %> +
  • <%= "#{I18n.l d, format: :long} #{I18n.l slot.start_at, format: :hour_minute} - #{I18n.l slot.end_at, format: :hour_minute}" %>
  • + <% end %> + <% else %> +
  • <%= "#{I18n.l slot.start_at, format: :long} - #{I18n.l slot.end_at, format: :hour_minute}" %>
  • + <% end %> +<% end %> +
diff --git a/config/locales/app.public.en.yml b/config/locales/app.public.en.yml index 5213b4a30..a7ea3ec94 100644 --- a/config/locales/app.public.en.yml +++ b/config/locales/app.public.en.yml @@ -332,9 +332,10 @@ en: thank_you_your_payment_has_been_successfully_registered: "Thank you. Your payment has been successfully registered!" thank_you_your_pre_registration_has_been_successfully_saved: "Thank you. Your pre-registration has been successfully saved!" you_can_find_your_reservation_s_details_on_your_: "You can find your reservation's details on your" + informed_by_email_your_pre_registration: "You will be kept informed by email of the progress made regarding your pre-registration." dashboard: "dashboard" you_booked_DATE: "You booked ({DATE}):" - you_pre_booked_DATE: "You pre-booked ({DATE}):" + you_pre_booked_DATE: "Your pre-registration ({DATE}):" canceled_reservation_SEATS: "Reservation canceled ({SEATS} seats)" book: "Book" confirm_and_pay: "Confirm and pay" @@ -364,7 +365,7 @@ en: share_on_twitter: "Share on Twitter" last_name_and_first_name: "Last name and first name" pre_book: "Pre-book" - pre_registration_end_date: "Pre-registration end date" + pre_registration_end_date: "Deadline for pre-registration" pre_registration: "Pre-registration" #public calendar calendar: diff --git a/config/locales/app.public.fr.yml b/config/locales/app.public.fr.yml index fa31475d7..303b3ca8b 100644 --- a/config/locales/app.public.fr.yml +++ b/config/locales/app.public.fr.yml @@ -330,11 +330,12 @@ fr: ticket: "{NUMBER, plural, =0{place} one{place} other{places}}" make_a_gift_of_this_reservation: "Offrir cette réservation" thank_you_your_payment_has_been_successfully_registered: "Merci. Votre paiement a bien été pris en compte !" - thank_you_your_pre_registration_has_been_successfully_saved: "Merci. Votre pré-inscription a bien été pris en compte !" + thank_you_your_pre_registration_has_been_successfully_saved: "Merci. Votre demande a bien été pris en compte !" you_can_find_your_reservation_s_details_on_your_: "Vous pouvez retrouver le détail de votre réservation sur votre" + informed_by_email_your_pre_registration: "vous serez tenu informé par email de la suite donnée à votre pré-inscription" dashboard: "tableau de bord" you_booked_DATE: "Vous avez réservé ({DATE}) :" - you_pre_booked_DATE: "Vous avez pré-réservé ({DATE}) :" + you_pre_booked_DATE: "Votre pré-inscription ({DATE}) :" canceled_reservation_SEATS: "Réservation annulée ({SEATS} places)" book: "Réserver" confirm_and_pay: "Valider et payer" @@ -363,8 +364,8 @@ fr: share_on_facebook: "Partager sur Facebook" share_on_twitter: "Partager sur Twitter" last_name_and_first_name: "Nom et prénom" - pre_book: "Pré-réserver" - pre_registration_end_date: "Date de fin de pré-réservation" + pre_book: "Pré-inscrire" + pre_registration_end_date: "Date limite de pré-inscription" pre_registration: "Pré-réservation" #public calendar calendar: diff --git a/config/locales/en.yml b/config/locales/en.yml index 6d389fcda..428cb324f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -286,6 +286,8 @@ en: an_abuse_was_reported_on_TYPE_ID_NAME_html: "An abuse was reported on %{TYPE} %{ID}: %{NAME}." notify_admin_member_create_reservation: a_RESERVABLE_reservation_was_made_by_USER_html: "A %{RESERVABLE} reservation was made by %{USER}." + notify_admin_member_pre_booked_reservation: + a_RESERVABLE_reservation_was_made_by_USER_html: "A %{RESERVABLE} pre-registration was made by %{USER}." notify_admin_profile_complete: account_imported_from_PROVIDER_UID_has_completed_its_information_html: "Account imported from %{PROVIDER} (%{UID}) has completed its information." notify_admin_slot_is_canceled: @@ -320,6 +322,8 @@ en: a_new_user_account_has_been_imported_from_PROVIDER_UID_html: "A new user account has been imported from: %{PROVIDER} (%{UID})." notify_member_create_reservation: your_reservation_RESERVABLE_was_successfully_saved_html: "Your reservation %{RESERVABLE} was successfully saved." + notify_member_pre_booked_reservation: + your_reservation_RESERVABLE_was_successfully_saved_html: "Your pre-registration %{RESERVABLE} was successfully saved." notify_member_reservation_reminder: reminder_you_have_a_reservation_RESERVABLE_to_be_held_on_DATE_html: "Reminder: You have a reservation %{RESERVABLE} to be held on %{DATE}" notify_member_slot_is_canceled: diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 2ed92fc91..f1446c56d 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -286,6 +286,8 @@ fr: an_abuse_was_reported_on_TYPE_ID_NAME_html: "Un abus a été signalé sur %{TYPE} %{ID} : %{NAME}." notify_admin_member_create_reservation: a_RESERVABLE_reservation_was_made_by_USER_html: "Une réservation %{RESERVABLE} a été effectuée par %{USER}." + notify_admin_member_pre_booked_reservation: + a_RESERVABLE_reservation_was_made_by_USER_html: "Une pre-inscription %{RESERVABLE} a été effectuée par %{USER}." notify_admin_profile_complete: account_imported_from_PROVIDER_UID_has_completed_its_information_html: "Le compte importé depuis %{PROVIDER} (%{UID}) a complété ses informations." notify_admin_slot_is_canceled: @@ -320,6 +322,8 @@ fr: a_new_user_account_has_been_imported_from_PROVIDER_UID_html: "Un nouveau compte utilisateur vient d'être importé depuis : %{PROVIDER} (%{UID})." notify_member_create_reservation: your_reservation_RESERVABLE_was_successfully_saved_html: "Votre réservation %{RESERVABLE} a bien été enregistrée." + notify_member_pre_booked_reservation: + your_reservation_RESERVABLE_was_successfully_saved_html: "Votre pré-inscription %{RESERVABLE} a bien été pris en compte." notify_member_reservation_reminder: reminder_you_have_a_reservation_RESERVABLE_to_be_held_on_DATE_html: "Rappel : Vous avez une réservation %{RESERVABLE} qui aura lieu le %{DATE}" notify_member_slot_is_canceled: diff --git a/config/locales/mails.en.yml b/config/locales/mails.en.yml index 63a6c2969..3cefad918 100644 --- a/config/locales/mails.en.yml +++ b/config/locales/mails.en.yml @@ -78,6 +78,11 @@ en: body: reservation_saved_html: "You reservation %{RESERVATION} has been successfully saved" your_reserved_slots: "Your reserved slots are:" + notify_member_pre_booked_reservation: + subject: "Your pre-registration has been successfully saved" + body: + reservation_saved_html: "You pre-registration %{RESERVATION} has been successfully saved" + your_reserved_slots: "Your pre-booked slots are:" notify_member_subscribed_plan_is_changed: subject: "Your subscription has been updated" body: @@ -87,6 +92,11 @@ en: body: member_reserved_html: "User %{NAME} has reserved %{RESERVABLE}." reserved_slots: "Reserved slots are:" + notify_admin_member_pre_booked_reservation: + subject: "New pre-registration" + body: + member_reserved_html: "User %{NAME} has pre-reserved %{RESERVABLE}." + reserved_slots: "Pre-reserved slots are:" notify_member_slot_is_modified: subject: "Your reservation slot has been successfully changed" body: diff --git a/config/locales/mails.fr.yml b/config/locales/mails.fr.yml index 1c7470606..b874511c3 100644 --- a/config/locales/mails.fr.yml +++ b/config/locales/mails.fr.yml @@ -78,6 +78,11 @@ fr: body: reservation_saved_html: "Votre réservation %{RESERVATION} a bien été enregistrée." your_reserved_slots: "Les créneaux que vous avez réservés sont :" + notify_member_pre_booked_reservation: + subject: "Votre pré-inscription a bien été pris en compte" + body: + reservation_saved_html: "Votre réservation %{RESERVATION} a bien été pris en compte." + your_reserved_slots: "Les créneaux que vous avez pré-inscrit sont :" notify_member_subscribed_plan_is_changed: subject: "Votre abonnement a été mis à jour" body: @@ -87,6 +92,11 @@ fr: body: member_reserved_html: "Le membre %{NAME} a réservé %{RESERVABLE}." reserved_slots: "Les créneaux réservés sont :" + notify_admin_member_pre_booked_reservation: + subject: "Nouvelle pre-inscription" + body: + member_reserved_html: "Le membre %{NAME} a pre-inscrit %{RESERVABLE}." + reserved_slots: "Les créneaux pre-inscrit sont :" notify_member_slot_is_modified: subject: "Votre créneau de réservation a bien été modifié" body: diff --git a/db/seeds/notification_types.rb b/db/seeds/notification_types.rb index 01e3ac99d..9cce6a6a5 100644 --- a/db/seeds/notification_types.rb +++ b/db/seeds/notification_types.rb @@ -90,7 +90,9 @@ NOTIFICATIONS_TYPES = [ { name: 'notify_admin_user_child_supporting_document_files_created', category: 'supporting_documents', is_configurable: true }, { name: 'notify_member_reservation_validated', category: 'agenda', is_configurable: false }, - { name: 'notify_admin_reservation_validated', category: 'agenda', is_configurable: true } + { name: 'notify_admin_reservation_validated', category: 'agenda', is_configurable: true }, + { name: 'notify_member_pre_booked_reservation', category: 'agenda', is_configurable: false }, + { name: 'notify_admin_member_pre_booked_reservation', category: 'agenda', is_configurable: true } ].freeze NOTIFICATIONS_TYPES.each do |notification_type| From 59fb10753d42c5122d95608491b319a68a18f1c0 Mon Sep 17 00:00:00 2001 From: Du Peng Date: Wed, 28 Jun 2023 18:23:07 +0200 Subject: [PATCH 4/4] (feat) some improvements for family account --- .../javascript/components/family-account/child-form.tsx | 1 + .../javascript/components/family-account/child-modal.tsx | 9 +++++---- .../components/family-account/child-validation.tsx | 6 +++--- .../src/javascript/components/user/members-list-item.tsx | 9 ++++++++- app/frontend/src/javascript/controllers/admin/members.js | 1 - app/frontend/templates/admin/events/monitoring.html | 8 ++++---- app/frontend/templates/admin/events/reservations.html | 8 ++++---- app/frontend/templates/events/show.html | 6 +++--- config/locales/app.admin.en.yml | 3 ++- config/locales/app.admin.fr.yml | 3 ++- config/locales/app.public.en.yml | 2 +- config/locales/app.public.fr.yml | 5 +++-- config/locales/fr.yml | 2 +- 13 files changed, 37 insertions(+), 26 deletions(-) diff --git a/app/frontend/src/javascript/components/family-account/child-form.tsx b/app/frontend/src/javascript/components/family-account/child-form.tsx index bc7ab29c1..f9e9b4a53 100644 --- a/app/frontend/src/javascript/components/family-account/child-form.tsx +++ b/app/frontend/src/javascript/components/family-account/child-form.tsx @@ -116,6 +116,7 @@ export const ChildForm: React.FC = ({ child, onSubmit, supportin defaultFile={sf as FileType} id={`supporting_document_files_attributes.${index}`} accept="application/pdf" + rules={{ required: true }} setValue={setValue} label={getSupportingDocumentsTypeName(sf.supporting_document_type_id)} showRemoveButton={false} diff --git a/app/frontend/src/javascript/components/family-account/child-modal.tsx b/app/frontend/src/javascript/components/family-account/child-modal.tsx index f950e207e..942dc60a2 100644 --- a/app/frontend/src/javascript/components/family-account/child-modal.tsx +++ b/app/frontend/src/javascript/components/family-account/child-modal.tsx @@ -28,14 +28,15 @@ export const ChildModal: React.FC = ({ child, isOpen, toggleMod * Save the child to the API */ const handleSaveChild = async (data: Child): Promise => { + let c: Child = data; try { if (child?.id) { - await ChildAPI.update(data); + c = await ChildAPI.update(data); } else { - await ChildAPI.create(data); + c = await ChildAPI.create(data); } toggleModal(); - onSuccess(data, ''); + onSuccess(c, ''); } catch (error) { onError(error); } @@ -56,7 +57,7 @@ export const ChildModal: React.FC = ({ child, isOpen, toggleMod onSubmit={handleSaveChild} supportingDocumentsTypes={supportingDocumentsTypes} operator={operator} - onSuccess={onSuccess} + onSuccess={(msg) => onSuccess(child, msg)} onError={onError} /> diff --git a/app/frontend/src/javascript/components/family-account/child-validation.tsx b/app/frontend/src/javascript/components/family-account/child-validation.tsx index 1705ad6cf..92f6db8db 100644 --- a/app/frontend/src/javascript/components/family-account/child-validation.tsx +++ b/app/frontend/src/javascript/components/family-account/child-validation.tsx @@ -9,7 +9,7 @@ import { TDateISO } from '../../typings/date-iso'; interface ChildValidationProps { child: Child - onSuccess: (message: string) => void, + onSuccess: (child: Child, msg: string) => void; onError: (message: string) => void, } @@ -37,8 +37,8 @@ export const ChildValidation: React.FC = ({ child, onSucce _child.validated_at = null; } ChildAPI.validate(_child) - .then(() => { - onSuccess(t(`app.admin.child_validation.${_value ? 'validate' : 'invalidate'}_child_success`)); + .then((c) => { + onSuccess(c, t(`app.admin.child_validation.${_value ? 'validate' : 'invalidate'}_child_success`)); }).catch(err => { setValue(!_value); onError(t(`app.admin.child_validation.${_value ? 'validate' : 'invalidate'}_child_error`) + err); diff --git a/app/frontend/src/javascript/components/user/members-list-item.tsx b/app/frontend/src/javascript/components/user/members-list-item.tsx index 4d0bea4f0..51b2458af 100644 --- a/app/frontend/src/javascript/components/user/members-list-item.tsx +++ b/app/frontend/src/javascript/components/user/members-list-item.tsx @@ -30,8 +30,15 @@ export const MembersListItem: React.FC = ({ member, onErro window.location.href = `/#!/admin/members/${memberId}/edit`; }; + /** + * member and all his children are validated + */ + const memberIsValidated = (): boolean => { + return member.validated_at && member.children.every((child) => child.validated_at); + }; + return ( -
+
{(member.children.length > 0) diff --git a/app/frontend/src/javascript/controllers/admin/members.js b/app/frontend/src/javascript/controllers/admin/members.js index e7b388827..e5593977d 100644 --- a/app/frontend/src/javascript/controllers/admin/members.js +++ b/app/frontend/src/javascript/controllers/admin/members.js @@ -322,7 +322,6 @@ Application.Controllers.controller('AdminMembersController', ['$scope', '$sce', } return c; }); - console.log(member.children); return member; } return member; diff --git a/app/frontend/templates/admin/events/monitoring.html b/app/frontend/templates/admin/events/monitoring.html index 01d8e9285..ed4aa9d61 100644 --- a/app/frontend/templates/admin/events/monitoring.html +++ b/app/frontend/templates/admin/events/monitoring.html @@ -50,10 +50,10 @@ - {{ 'app.admin.events.event_type.standard' }} - {{ 'app.admin.events.event_type.nominative' }} - {{ 'app.admin.events.event_type.family' }} - {{ 'app.admin.events.pre_registration' }} + {{ 'app.admin.events.event_type.standard' }} + {{ 'app.admin.events.event_type.nominative' }} + {{ 'app.admin.events.event_type.family' }} + {{ 'app.admin.events.pre_registration' }} diff --git a/app/frontend/templates/admin/events/reservations.html b/app/frontend/templates/admin/events/reservations.html index 02fc0b260..b2dad5e8d 100644 --- a/app/frontend/templates/admin/events/reservations.html +++ b/app/frontend/templates/admin/events/reservations.html @@ -46,10 +46,10 @@ {{ticket.event_price_category.price_category.name}} : {{ticket.booked}} - {{ 'app.admin.event_reservations.event_status.pre_registered' }} - {{ 'app.admin.event_reservations.event_status.to_pay' }} - {{ 'app.admin.event_reservations.event_status.paid' }} - {{ 'app.admin.event_reservations.event_status.canceled' }} + {{ 'app.admin.event_reservations.event_status.pre_registered' }} + {{ 'app.admin.event_reservations.event_status.to_pay' }} + {{ 'app.admin.event_reservations.event_status.paid' }} + {{ 'app.admin.event_reservations.event_status.canceled' }}