💩(frontend) restore user name / org header

This was added previously and while the organization is not displayed
elsewhere it's better to keep the information displayed somewhere.
This commit is contained in:
Quentin BEY
2025-05-09 10:10:57 +02:00
parent 3d9645b561
commit cb198a9d04
4 changed files with 30 additions and 7 deletions

View File

@@ -0,0 +1,20 @@
import { useTranslation } from 'react-i18next';
import { Box, Text } from '@/components';
import { useAuthStore } from '@/core/auth';
export const UserInfo = () => {
const { t } = useTranslation();
const { authenticated, userData } = useAuthStore();
const userName = userData?.name || userData?.email || t('No Username');
const organizationName = userData?.organization?.name || '';
return authenticated ? (
<Box $direction="column" $align="left">
<Text $theme="primary">
{userName}
{organizationName ? ` | ${organizationName}` : ''}
</Text>
</Box>
) : null;
};

View File

@@ -5,6 +5,7 @@ import { useTranslation } from 'react-i18next';
import { default as IconRegie } from '@/assets/logo-regie.svg?url';
import { Icon, StyledLink, Text } from '@/components/';
import { ButtonLogin } from '@/core/auth';
import { UserInfo } from '@/core/auth/UserInfo';
import { useCunninghamTheme } from '@/cunningham';
import { LanguagePicker } from '@/features/language';
import { useLeftPanelStore } from '@/features/left-panel';
@@ -107,6 +108,7 @@ export const Header = () => {
flexDirection: 'row',
}}
>
<UserInfo />
<ButtonLogin />
<LanguagePicker />
<LaGaufre />

View File

@@ -4,6 +4,7 @@ import { createGlobalStyle } from 'styled-components';
import { SeparatedSection } from '@/components/separators';
import { ButtonLogin } from '@/core';
import { UserInfo } from '@/core/auth/UserInfo';
import { LanguagePicker } from '@/features/language';
import { useLeftPanelStore } from '../stores';
@@ -99,6 +100,7 @@ export const LeftPanel = () => {
gap: 'var(--c--theme--spacings--sm)',
}}
>
<UserInfo />
<ButtonLogin />
<LanguagePicker />
</div>

View File

@@ -19,12 +19,11 @@ test.describe('OIDC interop with SIRET', () => {
});
});
test.describe('When a commune, display commune name below user name', () => {
test('it checks the name is added below the user name', async ({ page }) => {
const logout = page.getByRole('button', {
name: 'Marie Delamairie',
});
await expect(logout.getByText('Merlaut')).toBeVisible();
test.describe('When a commune, display commune name with user name', () => {
test('it checks the name is added with the user name', async ({ page }) => {
// check the name is displayed along with the organization name : name | org name
await expect(
page.getByRole('banner').getByText('Marie Delamairie | Merlaut'),
).toBeVisible();
});
});