From 671aa688044dba2505de82ab577588ca72fe778a Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Tue, 6 Aug 2024 17:49:02 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F(frontend)=20restore=20User?= =?UTF-8?q?=20Information=20in=20Settings=20Dialog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reintroduced user information in the settings dialog. This change allows users to see the account they are logged into, which is important for account management. An additional feature to update usernames will be added soon. Apologies to @manuhabitela for the oversight. --- .../settings/components/SettingsDialog.tsx | 28 +++++++++++++++++-- src/frontend/src/locales/de/settings.json | 5 ++++ src/frontend/src/locales/en/settings.json | 5 ++++ src/frontend/src/locales/fr/settings.json | 5 ++++ 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/frontend/src/features/settings/components/SettingsDialog.tsx b/src/frontend/src/features/settings/components/SettingsDialog.tsx index ea4aabfa..079a5699 100644 --- a/src/frontend/src/features/settings/components/SettingsDialog.tsx +++ b/src/frontend/src/features/settings/components/SettingsDialog.tsx @@ -1,14 +1,38 @@ -import { useTranslation } from 'react-i18next' +import { Trans, useTranslation } from 'react-i18next' import { useLanguageLabels } from '@/i18n/useLanguageLabels' -import { Dialog, type DialogProps, Field, H } from '@/primitives' +import { A, Badge, Dialog, type DialogProps, Field, H, P } from '@/primitives' +import { authUrl, logoutUrl, useUser } from '@/features/auth' export type SettingsDialogProps = Pick export const SettingsDialog = (props: SettingsDialogProps) => { const { t, i18n } = useTranslation('settings') + const { user, isLoggedIn } = useUser() const { languagesList, currentLanguage } = useLanguageLabels() return ( + {t('account.heading')} + {isLoggedIn ? ( + <> +

+ ]} + /> +

+

+ {t('logout', { ns: 'global' })} +

+ + ) : ( + <> +

{t('account.youAreNotLoggedIn')}

+

+ {t('login', { ns: 'global' })} +

+ + )} {t('language.heading')} {{user}}", + "heading": "Account", + "youAreNotLoggedIn": "You are not logged in." + }, "dialog": { "heading": "Settings" }, diff --git a/src/frontend/src/locales/fr/settings.json b/src/frontend/src/locales/fr/settings.json index a9c260e1..d5ddea2c 100644 --- a/src/frontend/src/locales/fr/settings.json +++ b/src/frontend/src/locales/fr/settings.json @@ -1,4 +1,9 @@ { + "account": { + "currentlyLoggedAs": "Vous êtes actuellement connecté en tant que <0>{{user}}", + "heading": "Compte", + "youAreNotLoggedIn": "Vous n'êtes pas connecté." + }, "dialog": { "heading": "Paramètres" },