From 68f618ad641d2729b1822b7d4e09d2f8479126ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Le=20Bihan?= Date: Wed, 22 Feb 2023 13:40:43 +0100 Subject: [PATCH] fixed the getUserInfo of API.ts --- front/API.ts | 39 +++++++++++++++++++++++++++++++++++- front/models/UserSettings.ts | 2 +- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/front/API.ts b/front/API.ts index 1b17bf4..c3623ed 100644 --- a/front/API.ts +++ b/front/API.ts @@ -82,9 +82,46 @@ export default class API { * Retrieve information of the currently authentified user */ public static async getUserInfo(): Promise { - return API.fetch({ + let me = await API.fetch({ route: '/auth/me' }); + + // /auth/me only returns username and id (it needs to be changed) + + let user = await API.fetch({ + route: `/users/${me.id}` + }); + + // this a dummy settings object, we will need to fetch the real one from the API + return { + id: user.id as number, + name: (user.username ?? user.name) as string, + email: user.email as string, + xp: 0, + premium: false, + metrics: {}, + settings: { + preferences: { + deviceId: 1, + micVolume: 10, + theme: 'system', + lang: 'fr', + difficulty: 'beg', + colorBlind: false + }, + notifications: { + pushNotif: false, + emailNotif: false, + trainNotif: false, + newSongNotif: false + }, + privacy: { + dataCollection: true, + customAd: true, + recommendation: true + } + }, + } as User; } public static async getUserSkills() { diff --git a/front/models/UserSettings.ts b/front/models/UserSettings.ts index 0a39b33..dbdd24d 100644 --- a/front/models/UserSettings.ts +++ b/front/models/UserSettings.ts @@ -15,7 +15,7 @@ interface UserSettings { }, privacy: { dataCollection: boolean, - customAdd: boolean, + customAd: boolean, recommendation: boolean } }