From 73e58e274c1462ff3fc337f7549948751e3dccea Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Mon, 25 Mar 2024 16:05:52 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8(app-desk)=20modal=20delete=20team?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We can now delete a team. --- src/frontend/apps/desk/cunningham.ts | 1 + .../desk/src/cunningham/cunningham-tokens.css | 1 + .../desk/src/cunningham/cunningham-tokens.ts | 1 + .../src/features/teams/assets/icon-trash.svg | 3 + .../teams/components/ModalRemoveTeam.tsx | 119 ++++++++++++++++++ 5 files changed, 125 insertions(+) create mode 100644 src/frontend/apps/desk/src/features/teams/assets/icon-trash.svg create mode 100644 src/frontend/apps/desk/src/features/teams/components/ModalRemoveTeam.tsx diff --git a/src/frontend/apps/desk/cunningham.ts b/src/frontend/apps/desk/cunningham.ts index c27c164..a179392 100644 --- a/src/frontend/apps/desk/cunningham.ts +++ b/src/frontend/apps/desk/cunningham.ts @@ -191,6 +191,7 @@ const config = { 'card-border': '#DDDDDD', 'primary-text': '#000091', 'primary-100': '#f5f5fe', + 'primary-150': '#F4F4FD', 'primary-200': '#ececfe', 'primary-300': '#e3e3fd', 'primary-400': '#cacafb', diff --git a/src/frontend/apps/desk/src/cunningham/cunningham-tokens.css b/src/frontend/apps/desk/src/cunningham/cunningham-tokens.css index 9b4cabe..0653c76 100644 --- a/src/frontend/apps/desk/src/cunningham/cunningham-tokens.css +++ b/src/frontend/apps/desk/src/cunningham/cunningham-tokens.css @@ -334,6 +334,7 @@ --c--theme--colors--card-border: #ddd; --c--theme--colors--primary-text: #000091; --c--theme--colors--primary-100: #f5f5fe; + --c--theme--colors--primary-150: #f4f4fd; --c--theme--colors--primary-200: #ececfe; --c--theme--colors--primary-300: #e3e3fd; --c--theme--colors--primary-400: #cacafb; diff --git a/src/frontend/apps/desk/src/cunningham/cunningham-tokens.ts b/src/frontend/apps/desk/src/cunningham/cunningham-tokens.ts index a10a26d..18a7942 100644 --- a/src/frontend/apps/desk/src/cunningham/cunningham-tokens.ts +++ b/src/frontend/apps/desk/src/cunningham/cunningham-tokens.ts @@ -335,6 +335,7 @@ export const tokens = { 'card-border': '#DDDDDD', 'primary-text': '#000091', 'primary-100': '#f5f5fe', + 'primary-150': '#F4F4FD', 'primary-200': '#ececfe', 'primary-300': '#e3e3fd', 'primary-400': '#cacafb', diff --git a/src/frontend/apps/desk/src/features/teams/assets/icon-trash.svg b/src/frontend/apps/desk/src/features/teams/assets/icon-trash.svg new file mode 100644 index 0000000..caa4e96 --- /dev/null +++ b/src/frontend/apps/desk/src/features/teams/assets/icon-trash.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/frontend/apps/desk/src/features/teams/components/ModalRemoveTeam.tsx b/src/frontend/apps/desk/src/features/teams/components/ModalRemoveTeam.tsx new file mode 100644 index 0000000..04d2d82 --- /dev/null +++ b/src/frontend/apps/desk/src/features/teams/components/ModalRemoveTeam.tsx @@ -0,0 +1,119 @@ +import { + Button, + Modal, + ModalSize, + VariantType, + useToastProvider, +} from '@openfun/cunningham-react'; +import { t } from 'i18next'; +import { useRouter } from 'next/navigation'; + +import IconGroup from '@/assets/icons/icon-group.svg'; +import { Box, Text, TextErrors } from '@/components'; +import useCunninghamTheme from '@/cunningham/useCunninghamTheme'; + +import { useRemoveTeam } from '../api/useRemoveTeam'; +import IconRemove from '../assets/icon-trash.svg'; +import { Team } from '../types'; + +interface ModalRemoveTeamProps { + onClose: () => void; + team: Team; +} + +export const ModalRemoveTeam = ({ onClose, team }: ModalRemoveTeamProps) => { + const { colorsTokens } = useCunninghamTheme(); + const { toast } = useToastProvider(); + const router = useRouter(); + + const { + mutate: removeTeam, + isError, + error, + } = useRemoveTeam({ + onSuccess: () => { + toast(t('The team has been removed.'), VariantType.SUCCESS, { + duration: 4000, + }); + router.push('/'); + }, + }); + + return ( + onClose()} + > + {t('Cancel')} + + } + onClose={() => onClose()} + rightActions={ + + } + size={ModalSize.MEDIUM} + title={ + + + + {t('Deleting the {{teamName}} team', { teamName: team.name })} + + + } + > + + + {t('Are you sure you want to delete {{teamName}} team?', { + teamName: team.name, + })} + + + {isError && } + + + + + {team.name} + + + + + ); +};