From 36caa82bfefd579733250622eb5ec71c380ba9ff Mon Sep 17 00:00:00 2001
From: Brieuc Dubois <git@bhasher.com>
Date: Wed, 9 Oct 2024 12:09:15 +0300
Subject: [PATCH] Fix #107

---
 frontend/src/lib/types/user.ts            | 6 +++---
 frontend/src/routes/register/+page.svelte | 3 ++-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/frontend/src/lib/types/user.ts b/frontend/src/lib/types/user.ts
index c3a53d8d..cb287f76 100644
--- a/frontend/src/lib/types/user.ts
+++ b/frontend/src/lib/types/user.ts
@@ -28,7 +28,7 @@ export default class User {
 	private _ui_language: string | null;
 	private _home_language: string | null;
 	private _target_language: string | null;
-	private _birthdate: number | null;
+	private _birthdate: Date | null;
 	private _gender: string | null;
 	private _calcom_link: string | null;
 	private _study_id: number | null;
@@ -44,7 +44,7 @@ export default class User {
 		ui_language: string | null,
 		home_language: string | null,
 		target_language: string | null,
-		birthdate: number | null,
+		birthdate: Date | null,
 		gender: string | null,
 		calcom_link: string | null,
 		study_id: number | null,
@@ -110,7 +110,7 @@ export default class User {
 		return this._target_language;
 	}
 
-	get birthdate(): number | null {
+	get birthdate(): Date | null {
 		return this._birthdate;
 	}
 
diff --git a/frontend/src/routes/register/+page.svelte b/frontend/src/routes/register/+page.svelte
index bb6692c1..64437b5a 100644
--- a/frontend/src/routes/register/+page.svelte
+++ b/frontend/src/routes/register/+page.svelte
@@ -18,6 +18,7 @@
 	import Typingtest from '$lib/components/tests/typingtest.svelte';
 	import AvailableTutors from '$lib/components/users/availableTutors.svelte';
 	import { browser } from '$app/environment';
+	import { formatToUTCDate } from '$lib/utils/date';
 
 	let current_step = 0;
 
@@ -388,7 +389,7 @@
 					id="birthyear"
 					name="birthyear"
 					required
-					bind:value={birthdate}
+					on:change={(e) => (birthdate = formatToUTCDate(new Date(e.target.value, 1, 1)))}
 				>
 					<option disabled selected value="">{$t('register.birthyear')}</option>
 					{#each Array.from({ length: 82 }, (_, i) => i + 1931).reverse() as year}
-- 
GitLab