-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add the team page, you can access to the team page with the id of the team. - Add link to the panel team to access to the team page.
- Loading branch information
Showing
6 changed files
with
162 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { Loader } from '@openfun/cunningham-react'; | ||
import { useRouter } from 'next/router'; | ||
import { ReactElement } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import { Box, Text } from '@/components'; | ||
import { useTeam } from '@/features/teams/api/useTeam'; | ||
import { NextPageWithLayout } from '@/types/next'; | ||
|
||
import TeamLayout from './TeamLayout'; | ||
|
||
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 { t } = useTranslation(); | ||
const { data: team, isLoading, isError } = useTeam({ id }); | ||
|
||
if (isError) { | ||
return ( | ||
<Text | ||
$align="center" | ||
$justify="center" | ||
$height="100%" | ||
$theme="danger" | ||
$textAlign="center" | ||
> | ||
{t('Something bad happens, please retry.')} | ||
</Text> | ||
); | ||
} | ||
|
||
if (isLoading) { | ||
return ( | ||
<Box $align="center" $justify="center" $height="100%"> | ||
<Loader /> | ||
</Box> | ||
); | ||
} | ||
|
||
return ( | ||
<Text as="h3" $textAlign="center"> | ||
Teams: {team?.name} | ||
</Text> | ||
); | ||
}; | ||
|
||
Page.getLayout = function getLayout(page: ReactElement) { | ||
return <TeamLayout>{page}</TeamLayout>; | ||
}; | ||
|
||
export default Page; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters