mirror of
https://github.com/suitenumerique/meet.git
synced 2026-08-07 01:13:21 +00:00
7ddf9070aa
Show email alongside full name when available to prevent user confusion about which account is currently logged in. Enhances general app UX.
52 lines
1.6 KiB
TypeScript
52 lines
1.6 KiB
TypeScript
import { Trans, useTranslation } from 'react-i18next'
|
|
import { useLanguageLabels } from '@/i18n/useLanguageLabels'
|
|
import { A, Badge, Dialog, type DialogProps, Field, H, P } from '@/primitives'
|
|
import { useUser } from '@/features/auth'
|
|
import { LoginButton } from '@/components/LoginButton'
|
|
|
|
export type SettingsDialogProps = Pick<DialogProps, 'isOpen' | 'onOpenChange'>
|
|
|
|
export const SettingsDialog = (props: SettingsDialogProps) => {
|
|
const { t, i18n } = useTranslation('settings')
|
|
const { user, isLoggedIn, logout } = useUser()
|
|
const { languagesList, currentLanguage } = useLanguageLabels()
|
|
const userDisplay =
|
|
user?.full_name && user?.email
|
|
? `${user.full_name} (${user.email})`
|
|
: user?.email
|
|
return (
|
|
<Dialog title={t('dialog.heading')} {...props}>
|
|
<H lvl={2}>{t('account.heading')}</H>
|
|
{isLoggedIn ? (
|
|
<>
|
|
<P>
|
|
<Trans
|
|
i18nKey="settings:account.currentlyLoggedAs"
|
|
values={{ user: userDisplay }}
|
|
components={[<Badge />]}
|
|
/>
|
|
</P>
|
|
<P>
|
|
<A onPress={logout}>{t('logout', { ns: 'global' })}</A>
|
|
</P>
|
|
</>
|
|
) : (
|
|
<>
|
|
<P>{t('account.youAreNotLoggedIn')}</P>
|
|
<LoginButton />
|
|
</>
|
|
)}
|
|
<H lvl={2}>{t('language.heading')}</H>
|
|
<Field
|
|
type="select"
|
|
label={t('language.label')}
|
|
items={languagesList}
|
|
defaultSelectedKey={currentLanguage.key}
|
|
onSelectionChange={(lang) => {
|
|
i18n.changeLanguage(lang as string)
|
|
}}
|
|
/>
|
|
</Dialog>
|
|
)
|
|
}
|