✨(frontend) show names in mailbox table
- show a concatenation of first and last names for each row in mailbox table - update related e2e tests
This commit is contained in:
committed by
Sebastien Nobour
parent
45dbdd6c4c
commit
7916f7d7d0
@@ -1,3 +1,5 @@
|
|||||||
|
import { UUID } from 'crypto';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
DataGrid,
|
DataGrid,
|
||||||
@@ -17,7 +19,11 @@ import { MailDomain, MailDomainMailbox } from '../types';
|
|||||||
|
|
||||||
import { CreateMailboxForm } from './forms/CreateMailboxForm';
|
import { CreateMailboxForm } from './forms/CreateMailboxForm';
|
||||||
|
|
||||||
export type ViewMailbox = { email: string; id: string };
|
export type ViewMailbox = {
|
||||||
|
name: string;
|
||||||
|
email: string;
|
||||||
|
id: UUID;
|
||||||
|
};
|
||||||
|
|
||||||
// FIXME : ask Cunningham to export this type
|
// FIXME : ask Cunningham to export this type
|
||||||
type SortModelItem = {
|
type SortModelItem = {
|
||||||
@@ -69,6 +75,7 @@ export function MailDomainsContent({ mailDomain }: { mailDomain: MailDomain }) {
|
|||||||
mailDomain && data?.results?.length
|
mailDomain && data?.results?.length
|
||||||
? data.results.map((mailbox: MailDomainMailbox) => ({
|
? data.results.map((mailbox: MailDomainMailbox) => ({
|
||||||
email: `${mailbox.local_part}@${mailDomain.name}`,
|
email: `${mailbox.local_part}@${mailDomain.name}`,
|
||||||
|
name: `${mailbox.first_name} ${mailbox.last_name}`,
|
||||||
id: mailbox.id,
|
id: mailbox.id,
|
||||||
}))
|
}))
|
||||||
: [];
|
: [];
|
||||||
@@ -76,6 +83,7 @@ export function MailDomainsContent({ mailDomain }: { mailDomain: MailDomain }) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setPagesCount(data?.count ? Math.ceil(data.count / pageSize) : 0);
|
setPagesCount(data?.count ? Math.ceil(data.count / pageSize) : 0);
|
||||||
}, [data?.count, pageSize, setPagesCount]);
|
}, [data?.count, pageSize, setPagesCount]);
|
||||||
|
|
||||||
return isLoading ? (
|
return isLoading ? (
|
||||||
<Box $align="center" $justify="center" $height="100%">
|
<Box $align="center" $justify="center" $height="100%">
|
||||||
<Loader />
|
<Loader />
|
||||||
@@ -88,19 +96,35 @@ export function MailDomainsContent({ mailDomain }: { mailDomain: MailDomain }) {
|
|||||||
closeModal={() => setIsCreateMailboxFormVisible(false)}
|
closeModal={() => setIsCreateMailboxFormVisible(false)}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
<TopBanner
|
<TopBanner
|
||||||
name={mailDomain.name}
|
name={mailDomain.name}
|
||||||
setIsFormVisible={setIsCreateMailboxFormVisible}
|
setIsFormVisible={setIsCreateMailboxFormVisible}
|
||||||
abilities={mailDomain.abilities}
|
abilities={mailDomain?.abilities}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Card
|
<Card
|
||||||
$padding={{ bottom: 'small' }}
|
$padding={{ bottom: 'small' }}
|
||||||
$margin={{ all: 'big', top: 'none' }}
|
$margin={{ all: 'big', top: 'none' }}
|
||||||
$overflow="auto"
|
$overflow="auto"
|
||||||
>
|
>
|
||||||
{error && <TextErrors causes={error.cause} />}
|
{error && <TextErrors causes={error.cause} />}
|
||||||
|
|
||||||
<DataGrid
|
<DataGrid
|
||||||
columns={[
|
columns={[
|
||||||
|
{
|
||||||
|
field: 'name',
|
||||||
|
headerName: t('Names'),
|
||||||
|
renderCell: ({ row }) => (
|
||||||
|
<Text
|
||||||
|
$weight="bold"
|
||||||
|
$theme="primary"
|
||||||
|
$css="text-transform: capitalize;"
|
||||||
|
>
|
||||||
|
{row.name}
|
||||||
|
</Text>
|
||||||
|
),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
field: 'email',
|
field: 'email',
|
||||||
headerName: t('Emails'),
|
headerName: t('Emails'),
|
||||||
|
|||||||
@@ -19,5 +19,7 @@ export interface MailDomain {
|
|||||||
export interface MailDomainMailbox {
|
export interface MailDomainMailbox {
|
||||||
id: UUID;
|
id: UUID;
|
||||||
local_part: string;
|
local_part: string;
|
||||||
|
first_name: string;
|
||||||
|
last_name: string;
|
||||||
secondary_email: string;
|
secondary_email: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,11 +163,15 @@ test.describe('Mail domain', () => {
|
|||||||
domainFr: {
|
domainFr: {
|
||||||
page1: Array.from({ length: 20 }, (_, i) => ({
|
page1: Array.from({ length: 20 }, (_, i) => ({
|
||||||
id: `456ac6ca-0402-4615-8005-69bc1efde${i}f`,
|
id: `456ac6ca-0402-4615-8005-69bc1efde${i}f`,
|
||||||
|
first_name: 'john',
|
||||||
|
last_name: 'doe',
|
||||||
local_part: `local_part-${i}`,
|
local_part: `local_part-${i}`,
|
||||||
secondary_email: `secondary_email-${i}`,
|
secondary_email: `secondary_email-${i}`,
|
||||||
})),
|
})),
|
||||||
page2: Array.from({ length: 2 }, (_, i) => ({
|
page2: Array.from({ length: 2 }, (_, i) => ({
|
||||||
id: `456ac6ca-0402-4615-8005-69bc1efde${i}d`,
|
id: `456ac6ca-0402-4615-8005-69bc1efde${i}d`,
|
||||||
|
first_name: 'john',
|
||||||
|
last_name: 'doe',
|
||||||
local_part: `local_part-${i}`,
|
local_part: `local_part-${i}`,
|
||||||
secondary_email: `secondary_email-${i}`,
|
secondary_email: `secondary_email-${i}`,
|
||||||
})),
|
})),
|
||||||
@@ -235,6 +239,10 @@ test.describe('Mail domain', () => {
|
|||||||
page.getByRole('heading', { name: 'domain.fr' }),
|
page.getByRole('heading', { name: 'domain.fr' }),
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
page.getByRole('button', { name: /Names/ }).first(),
|
||||||
|
).toBeVisible();
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
page.getByRole('button', { name: /Emails/ }).first(),
|
page.getByRole('button', { name: /Emails/ }).first(),
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
@@ -249,6 +257,12 @@ test.describe('Mail domain', () => {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const table = page.locator('table');
|
||||||
|
await expect(table).toBeVisible();
|
||||||
|
|
||||||
|
const tdNames = await table.getByText('John Doe').all();
|
||||||
|
expect(tdNames.length).toEqual(20);
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
page.locator('.c__pagination__list').getByRole('button', { name: '1' }),
|
page.locator('.c__pagination__list').getByRole('button', { name: '1' }),
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
|
|||||||
Reference in New Issue
Block a user