From dd97a23ce70fc564d3142eb9d218ff1a929107b1 Mon Sep 17 00:00:00 2001
From: tusooa <tusooa@kazv.moe>
Date: Sun, 22 Jan 2023 11:15:52 -0500
Subject: Add birthday to registration form

---
 src/components/registration/registration.vue | 34 ++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

(limited to 'src/components/registration/registration.vue')

diff --git a/src/components/registration/registration.vue b/src/components/registration/registration.vue
index a26162f0..6d7fe76e 100644
--- a/src/components/registration/registration.vue
+++ b/src/components/registration/registration.vue
@@ -167,6 +167,40 @@
               </ul>
             </div>
 
+            <div
+              class="form-group"
+              :class="{ 'form-group--error': v$.user.birthday.$error }"
+            >
+              <label
+                class="form--label"
+                for="sign-up-birthday"
+              >
+                {{ birthdayRequired ? $t('registration.birthday') : $t('registration.birthday_optional') }}
+              </label>
+              <input
+                id="sign-up-birthday"
+                v-model="user.birthday"
+                :disabled="isPending"
+                class="form-control"
+                type="date"
+                max="birthdayMin"
+                :aria-required="birthdayRequired"
+              >
+            </div>
+            <div
+              v-if="v$.user.birthday.$dirty"
+              class="form-error"
+            >
+              <ul>
+                <li v-if="v$.user.birthday.required.$invalid">
+                  <span>{{ $t('registration.validations.birthday_required') }}</span>
+                </li>
+                <li v-if="v$.user.birthday.maxValue.$invalid">
+                  <span>{{ $tc('registration.validations.birthday_min_age', { date: birthdayMinFormatted }) }}</span>
+                </li>
+              </ul>
+            </div>
+
             <div
               class="form-group"
               :class="{ 'form-group--error': v$.user.language.$error }"
-- 
cgit v1.2.3-70-g09d2


From 03d5c2e140fc70937d3533665fa88d055ab486f1 Mon Sep 17 00:00:00 2001
From: tusooa <tusooa@kazv.moe>
Date: Sun, 22 Jan 2023 11:22:24 -0500
Subject: Make date picker aware of the birthday max value

---
 src/components/registration/registration.js  | 3 +++
 src/components/registration/registration.vue | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

(limited to 'src/components/registration/registration.vue')

diff --git a/src/components/registration/registration.js b/src/components/registration/registration.js
index 3139bdd2..22ca6ad6 100644
--- a/src/components/registration/registration.js
+++ b/src/components/registration/registration.js
@@ -71,6 +71,9 @@ const registration = {
       minDate.setTime(today.getTime() - minAge * DAY)
       return minDate
     },
+    birthdayMinAttr () {
+      return this.birthdayMin.toJSON().replace(/T.+$/, '')
+    },
     birthdayMinFormatted () {
       const browserLocale = localeService.internalToBrowserLocale(this.$i18n.locale)
       return this.user.birthday && new Date(Date.parse(this.birthdayMin)).toLocaleDateString(browserLocale, { timeZone: 'UTC', day: 'numeric', month: 'long', year: 'numeric' })
diff --git a/src/components/registration/registration.vue b/src/components/registration/registration.vue
index 6d7fe76e..5701b05e 100644
--- a/src/components/registration/registration.vue
+++ b/src/components/registration/registration.vue
@@ -183,7 +183,7 @@
                 :disabled="isPending"
                 class="form-control"
                 type="date"
-                max="birthdayMin"
+                :max="birthdayRequired ? birthdayMinAttr : undefined"
                 :aria-required="birthdayRequired"
               >
             </div>
-- 
cgit v1.2.3-70-g09d2

