🔥(app-impress) remove teams pages

Remove teams pages from the next router.
This commit is contained in:
Anthony LC
2024-04-03 16:06:31 +02:00
committed by Anthony LC
parent 3e6f20aedd
commit 352d4f6d27
3 changed files with 0 additions and 116 deletions

View File

@@ -1,67 +0,0 @@
import { Loader } from '@openfun/cunningham-react';
import { useRouter as useNavigate } from 'next/navigation';
import { useRouter } from 'next/router';
import { ReactElement } from 'react';
import { Box } from '@/components';
import { TextErrors } from '@/components/TextErrors';
import { MemberGrid } from '@/features/members';
import { Role, TeamInfo, TeamLayout, useTeam } from '@/features/teams/';
import { NextPageWithLayout } from '@/types/next';
const Page: NextPageWithLayout = () => {
const {
query: { id },
} = useRouter();
if (typeof id !== 'string') {
throw new Error('Invalid team id');
}
return <Team id={id} />;
};
interface TeamProps {
id: string;
}
const Team = ({ id }: TeamProps) => {
const { data: team, isLoading, isError, error } = useTeam({ id });
const navigate = useNavigate();
if (isError && error) {
if (error.status === 404) {
navigate.replace(`/404`);
return null;
}
return <TextErrors causes={error.cause} />;
}
if (isLoading || !team) {
return (
<Box $align="center" $justify="center" $height="100%">
<Loader />
</Box>
);
}
const currentRole = team.abilities.delete
? Role.OWNER
: team.abilities.manage_accesses
? Role.ADMIN
: Role.MEMBER;
return (
<>
<TeamInfo team={team} currentRole={currentRole} />
<MemberGrid team={team} currentRole={currentRole} />
</>
);
};
Page.getLayout = function getLayout(page: ReactElement) {
return <TeamLayout>{page}</TeamLayout>;
};
export default Page;

View File

@@ -1,19 +0,0 @@
import { ReactElement } from 'react';
import { Box } from '@/components';
import { CardCreateTeam, TeamLayout } from '@/features/teams/';
import { NextPageWithLayout } from '@/types/next';
const Page: NextPageWithLayout = () => {
return (
<Box className="p-l" $justify="center" $align="start" $height="inherit">
<CardCreateTeam />
</Box>
);
};
Page.getLayout = function getLayout(page: ReactElement) {
return <TeamLayout>{page}</TeamLayout>;
};
export default Page;

View File

@@ -1,30 +0,0 @@
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 { TeamLayout } from '@/features/teams/';
import { NextPageWithLayout } from '@/types/next';
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;