🚚(app-desk) alias home with teams url path
In order the keep the url path consistent and correctly structured, the homepage is aliased with the teams page.
This commit is contained in:
@@ -1,27 +1,12 @@
|
|||||||
import { Button } from '@openfun/cunningham-react';
|
|
||||||
import type { ReactElement } from 'react';
|
import type { ReactElement } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
import styled from 'styled-components';
|
|
||||||
|
|
||||||
import { Box, StyledLink } from '@/components';
|
|
||||||
import { NextPageWithLayout } from '@/types/next';
|
import { NextPageWithLayout } from '@/types/next';
|
||||||
|
|
||||||
|
import Teams from './teams/';
|
||||||
import TeamLayout from './teams/TeamLayout';
|
import TeamLayout from './teams/TeamLayout';
|
||||||
|
|
||||||
const StyledButton = styled(Button)`
|
|
||||||
width: fit-content;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const Page: NextPageWithLayout = () => {
|
const Page: NextPageWithLayout = () => {
|
||||||
const { t } = useTranslation();
|
return <Teams />;
|
||||||
|
|
||||||
return (
|
|
||||||
<Box $align="center" $justify="center" $height="inherit">
|
|
||||||
<StyledLink href="/teams/create">
|
|
||||||
<StyledButton>{t('Create a new team')}</StyledButton>
|
|
||||||
</StyledLink>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Page.getLayout = function getLayout(page: ReactElement) {
|
Page.getLayout = function getLayout(page: ReactElement) {
|
||||||
|
|||||||
31
src/frontend/apps/desk/src/pages/teams/index.tsx
Normal file
31
src/frontend/apps/desk/src/pages/teams/index.tsx
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import { Button } from '@openfun/cunningham-react';
|
||||||
|
import type { ReactElement } from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
import { Box, StyledLink } from '@/components';
|
||||||
|
import { NextPageWithLayout } from '@/types/next';
|
||||||
|
|
||||||
|
import TeamLayout from './TeamLayout';
|
||||||
|
|
||||||
|
const StyledButton = styled(Button)`
|
||||||
|
width: fit-content;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const Page: NextPageWithLayout = () => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box $align="center" $justify="center" $height="inherit">
|
||||||
|
<StyledLink href="/teams/create">
|
||||||
|
<StyledButton>{t('Create a new team')}</StyledButton>
|
||||||
|
</StyledLink>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
Page.getLayout = function getLayout(page: ReactElement) {
|
||||||
|
return <TeamLayout>{page}</TeamLayout>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Page;
|
||||||
@@ -80,4 +80,18 @@ test.describe('Teams Create', () => {
|
|||||||
await panel.locator('li').getByText(teamName).click();
|
await panel.locator('li').getByText(teamName).click();
|
||||||
await expect(elTeam).toBeVisible();
|
await expect(elTeam).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('checks alias teams url with homepage', async ({ page }) => {
|
||||||
|
await expect(page).toHaveURL('/');
|
||||||
|
|
||||||
|
const buttonCreateHomepage = page.getByRole('button', {
|
||||||
|
name: 'Create a new team',
|
||||||
|
});
|
||||||
|
|
||||||
|
await expect(buttonCreateHomepage).toBeVisible();
|
||||||
|
|
||||||
|
await page.goto('/teams');
|
||||||
|
await expect(buttonCreateHomepage).toBeVisible();
|
||||||
|
await expect(page).toHaveURL(/\/teams$/);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user