diff --git a/src/frontend/apps/desk/src/features/teams/components/CardCreateTeam.tsx b/src/frontend/apps/desk/src/features/teams/components/CardCreateTeam.tsx new file mode 100644 index 0000000..a5e41cc --- /dev/null +++ b/src/frontend/apps/desk/src/features/teams/components/CardCreateTeam.tsx @@ -0,0 +1,73 @@ +import { Button, Input, Loader } from '@openfun/cunningham-react'; +import { useRouter } from 'next/navigation'; +import { useState } from 'react'; +import { useTranslation } from 'react-i18next'; + +import IconGroup from '@/assets/icons/icon-group2.svg'; +import { Box, Card, StyledLink, Text, TextErrors } from '@/components'; +import { useCunninghamTheme } from '@/cunningham'; + +import { useCreateTeam } from '../api'; + +export const CardCreateTeam = () => { + const { t } = useTranslation(); + const router = useRouter(); + const { + mutate: createTeam, + isError, + isPending, + error, + } = useCreateTeam({ + onSuccess: (team) => { + router.push(`/teams/${team.id}`); + }, + }); + const [teamName, setTeamName] = useState(''); + const { colorsTokens } = useCunninghamTheme(); + + return ( + + + + + + {t('Name the team')} + + + setTeamName(e.target.value)} + rightIcon={edit} + /> + {isError && error && } + {isPending && ( + + + + )} + + + + + + + + + ); +}; diff --git a/src/frontend/apps/desk/src/features/teams/components/index.ts b/src/frontend/apps/desk/src/features/teams/components/index.ts index 38dec09..92dda9f 100644 --- a/src/frontend/apps/desk/src/features/teams/components/index.ts +++ b/src/frontend/apps/desk/src/features/teams/components/index.ts @@ -1,2 +1,3 @@ +export * from './CardCreateTeam'; export * from './Panel/Panel'; export * from './TeamInfo'; diff --git a/src/frontend/apps/desk/src/pages/teams/create.tsx b/src/frontend/apps/desk/src/pages/teams/create.tsx index 4498b76..59f3233 100644 --- a/src/frontend/apps/desk/src/pages/teams/create.tsx +++ b/src/frontend/apps/desk/src/pages/teams/create.tsx @@ -1,78 +1,15 @@ -import { Button, Input, Loader } from '@openfun/cunningham-react'; -import { useRouter } from 'next/navigation'; -import { ReactElement, useState } from 'react'; -import { useTranslation } from 'react-i18next'; +import { ReactElement } from 'react'; -import IconGroup from '@/assets/icons/icon-group2.svg'; -import { Box, Card, StyledLink, Text } from '@/components'; -import { TextErrors } from '@/components/TextErrors'; -import { useCunninghamTheme } from '@/cunningham'; -import { useCreateTeam } from '@/features/teams'; +import { Box } from '@/components'; +import { CardCreateTeam } from '@/features/teams'; import { NextPageWithLayout } from '@/types/next'; import TeamLayout from './TeamLayout'; const Page: NextPageWithLayout = () => { - const { t } = useTranslation(); - const router = useRouter(); - const { - mutate: createTeam, - isError, - isPending, - error, - } = useCreateTeam({ - onSuccess: (team) => { - router.push(`/teams/${team.id}`); - }, - }); - const [teamName, setTeamName] = useState(''); - const { colorsTokens } = useCunninghamTheme(); - return ( - - - - - - {t('Name the team')} - - - setTeamName(e.target.value)} - rightIcon={edit} - /> - {isError && error && } - {isPending && ( - - - - )} - - - - - - - - + ); };