From 010da264e846ad24c3212a3e40a7589723bf0542 Mon Sep 17 00:00:00 2001 From: Du Peng Date: Mon, 29 May 2023 15:10:22 +0200 Subject: [PATCH] (feat) add birthday alert for event reservation --- .../src/javascript/controllers/events.js.erb | 7 ++++++- app/frontend/templates/events/show.html | 12 ++++++++++++ config/locales/app.shared.en.yml | 1 + config/locales/app.shared.fr.yml | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/frontend/src/javascript/controllers/events.js.erb b/app/frontend/src/javascript/controllers/events.js.erb index 763b866a7..0c7a86483 100644 --- a/app/frontend/src/javascript/controllers/events.js.erb +++ b/app/frontend/src/javascript/controllers/events.js.erb @@ -647,6 +647,10 @@ Application.Controllers.controller('ShowEventController', ['$scope', '$state', ' return true; } + $scope.isUnder18YearsAgo = (date) => { + return moment(date).isAfter(moment().subtract(18, 'year')); + } + /* PRIVATE SCOPE */ /** @@ -738,7 +742,8 @@ Application.Controllers.controller('ShowEventController', ['$scope', '$state', ' name: child.first_name + ' ' + child.last_name, id: child.id, type: 'Child', - validatedAt: child.validated_at + validatedAt: child.validated_at, + birthday: child.birthday }); } } diff --git a/app/frontend/templates/events/show.html b/app/frontend/templates/events/show.html index f54a21616..0b4aeb048 100644 --- a/app/frontend/templates/events/show.html +++ b/app/frontend/templates/events/show.html @@ -142,6 +142,12 @@ {{ 'app.shared.cart.child_validation_required_alert' }}

+ +

+ + {{ 'app.shared.cart.child_birthday_must_be_under_18_years_ago_alert' }} +

+
@@ -174,6 +180,12 @@ {{ 'app.shared.cart.child_validation_required_alert' }}

+ +

+ + {{ 'app.shared.cart.child_birthday_must_be_under_18_years_ago_alert' }} +

+
diff --git a/config/locales/app.shared.en.yml b/config/locales/app.shared.en.yml index 961fd3bc7..0d08f0d8a 100644 --- a/config/locales/app.shared.en.yml +++ b/config/locales/app.shared.en.yml @@ -370,6 +370,7 @@ en: no_tags: "No tags" user_validation_required_alert: "Warning!
Your administrator must validate your account. Then, you'll then be able to access all the booking features." child_validation_required_alert: "Warning!
Your administrator must validate your child account. Then, you'll then be able to book the event." + child_birthday_must_be_under_18_years_ago_alert: "Warning!
Your child must be under 18 years ago. Then, you'll then be able to book the event." # feature-tour modal tour: previous: "Previous" diff --git a/config/locales/app.shared.fr.yml b/config/locales/app.shared.fr.yml index c0cab0930..e11b94748 100644 --- a/config/locales/app.shared.fr.yml +++ b/config/locales/app.shared.fr.yml @@ -370,6 +370,7 @@ fr: no_tags: "Aucune étiquette" user_validation_required_alert: "Attention !
Votre administrateur doit valider votre compte. Vous pourrez alors accéder à l'ensemble des fonctionnalités de réservation." child_validation_required_alert: "Attention !
Votre administrateur doit valider votre compte enfant. Vous pourrez alors réserver l'événement." + child_birthday_must_be_under_18_years_ago_alert: "Attention !
La date de naissance de l'enfant doit être inférieure à 18 ans. Vous pourrez alors réserver l'événement." #feature-tour modal tour: previous: "Précédent"