From 20f5398c2ca0db6b7352c3e10f0d7a4fe9cbf9c7 Mon Sep 17 00:00:00 2001 From: Arif Date: Fri, 12 Jul 2024 15:47:18 +0530 Subject: [PATCH 1/2] Issue #PS-1282 feat: Implement the delete center --- public/locales/en/common.json | 4 +- public/locales/hi/common.json | 4 +- public/locales/mr/common.json | 4 +- public/locales/or/common.json | 4 +- src/components/center/DeleteCenterModal.tsx | 120 ++++++++++++++++++++ src/pages/centers/[cohortId].tsx | 15 ++- 6 files changed, 145 insertions(+), 6 deletions(-) create mode 100644 src/components/center/DeleteCenterModal.tsx diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 1405d6a1..fa71ff21 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -288,7 +288,9 @@ "RENAME_CENTER": "Rename Center", "REQUEST_TO_DELETE": "Request to Delete", "RENAME": "Rename", - "CENTER_RENAMED": "Center Renamed Successfully!" + "CENTER_RENAMED": "Center Renamed Successfully!", + "SEND_REQUEST":"Send Request", + "REQUEST_TO_DELETE_HAS_BEEN_SENT": "Request to Delete has been sent" }, "MANAGE_USERS": { "CENTERS_REQUESTED_SUCCESSFULLY": "Center Requested Successfully" diff --git a/public/locales/hi/common.json b/public/locales/hi/common.json index d623f845..36f1db5d 100644 --- a/public/locales/hi/common.json +++ b/public/locales/hi/common.json @@ -267,6 +267,8 @@ "RENAME_CENTER": " केंद्र का नाम बदलें", "REQUEST_TO_DELETE": "हटाने का अनुरोध", "RENAME": "नाम बदलें", - "CENTER_RENAMED": "केंद्र का नाम सफलतापूर्वक बदल दिया गया!" + "CENTER_RENAMED": "केंद्र का नाम सफलतापूर्वक बदल दिया गया!", + "SEND_REQUEST":"अनुरोध भेजें", + "REQUEST_TO_DELETE_HAS_BEEN_SENT": " हटाने का अनुरोध भेजा गया है" } } diff --git a/public/locales/mr/common.json b/public/locales/mr/common.json index eefc9739..8e03e238 100644 --- a/public/locales/mr/common.json +++ b/public/locales/mr/common.json @@ -268,6 +268,8 @@ "RENAME_CENTER": "केंद्राचे नाव बदला", "REQUEST_TO_DELETE": "हटवण्याची विनंती", "RENAME": "नाव बदला", - "CENTER_RENAMED": "केंद्राचे नाव यशस्वीरित्या बदलले गेले!" + "CENTER_RENAMED": "केंद्राचे नाव यशस्वीरित्या बदलले गेले!", + "SEND_REQUEST":"विनंती पाठवा", + "REQUEST_TO_DELETE_HAS_BEEN_SENT": "हटवण्याची विनंती पाठवली आहे" } } diff --git a/public/locales/or/common.json b/public/locales/or/common.json index c28bf564..e97aae8f 100644 --- a/public/locales/or/common.json +++ b/public/locales/or/common.json @@ -212,7 +212,9 @@ "RENAME_CENTER": "କେନ୍ଦ୍ରର ନାମ ପରିବର୍ତ୍ତନ କରନ୍ତୁ", "REQUEST_TO_DELETE": "ହଟାଇବାକୁ ଅନୁରୋଧ", "RENAME": "ପୁନ ame ନାମ କରନ୍ତୁ", - "CENTER_RENAMED": "କେନ୍ଦ୍ରର ନାମ ସଫଳତାର ସହ ଚାଲିଛି!" + "CENTER_RENAMED": "କେନ୍ଦ୍ରର ନାମ ସଫଳତାର ସହ ଚାଲିଛି!", + "SEND_REQUEST":"ଅନୁରୋଧ ପଠାନ୍ତୁ", + "REQUEST_TO_DELETE_HAS_BEEN_SENT": "ହଟାଇବାକୁ ଅନୁରୋଧ ପଠାଯାଇଛି" } } diff --git a/src/components/center/DeleteCenterModal.tsx b/src/components/center/DeleteCenterModal.tsx new file mode 100644 index 00000000..314a8f48 --- /dev/null +++ b/src/components/center/DeleteCenterModal.tsx @@ -0,0 +1,120 @@ +import React, { useState } from 'react'; +import { + Box, + Typography, + TextField, + Button, + Modal, + Fade, + Divider, + IconButton, + Radio, + RadioGroup, + FormControlLabel, + FormControl, + FormLabel, +} from '@mui/material'; +import CloseIcon from '@mui/icons-material/Close'; +import { useTranslation } from 'next-i18next'; +import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; +import { useTheme, styled } from '@mui/material/styles'; +import { showToastMessage } from '../Toastify'; + +interface CreateBlockModalProps { + open: boolean; + handleClose: () => void; +} + +const CustomRadio = styled(Radio)(({ theme }) => ({ + color: theme.palette.text.primary, + '&.Mui-checked': { + color: theme.palette.text.primary, + }, +})); + +const DeleteCenterModal: React.FC = ({ + open, + handleClose, +}) => { + const { t } = useTranslation(); + const theme = useTheme(); + + + + const handleDeleteButtonClick = () => { + console.log('Delete request sent'); + showToastMessage(t('CENTERS.REQUEST_TO_DELETE_HAS_BEEN_SENT'), 'success'); + handleClose(); + }; + + return ( + + + + + + + + + You are sending a request to the State Admin to delete this Center + + + + + + + + + + ); +}; + +export default DeleteCenterModal; diff --git a/src/pages/centers/[cohortId].tsx b/src/pages/centers/[cohortId].tsx index 085674ae..7d68146c 100644 --- a/src/pages/centers/[cohortId].tsx +++ b/src/pages/centers/[cohortId].tsx @@ -41,6 +41,7 @@ import MoreVertIcon from '@mui/icons-material/MoreVert'; import ModeEditOutlineOutlinedIcon from '@mui/icons-material/ModeEditOutlineOutlined'; import DeleteOutlineOutlinedIcon from '@mui/icons-material/DeleteOutlineOutlined'; import RenameCenterModal from '@/components/center/RenameCenterModal'; +import DeleteCenterModal from '@/components/center/DeleteCenterModal'; const TeachingCenterDetails = () => { const [value, setValue] = React.useState(1); @@ -60,6 +61,8 @@ const TeachingCenterDetails = () => { React.useState(null); const [openRenameCenterModal, setOpenRenameCenterModal] = React.useState(false); + const [openDeleteCenterModal, setOpenDeleteCenterModal] = + React.useState(false); useEffect(() => { const getCohortData = async () => { @@ -125,6 +128,10 @@ const TeachingCenterDetails = () => { setOpenRenameCenterModal(false); }; + const handleDeleteCenterClose = () => { + setOpenDeleteCenterModal(false); + }; + return ( <>
@@ -186,13 +193,13 @@ const TeachingCenterDetails = () => { open={Boolean(anchorEl)} onClose={handleMenuClose} > - setOpenRenameCenterModal(true)}> + { setOpenRenameCenterModal(true); handleMenuClose(); }}> {t('CENTERS.RENAME_CENTER')} - + {setOpenDeleteCenterModal(true); handleMenuClose(); }}> @@ -203,6 +210,10 @@ const TeachingCenterDetails = () => { open={openRenameCenterModal} handleClose={handleRenameCenterClose} /> + From c06e67e8210946da0d15183ab5188e1b7baad25c Mon Sep 17 00:00:00 2001 From: Arif Date: Fri, 12 Jul 2024 18:07:43 +0530 Subject: [PATCH 2/2] Issue #PS-1282 feat: Implement the delete center --- public/locales/en/common.json | 3 ++- public/locales/hi/common.json | 3 ++- public/locales/mr/common.json | 3 ++- public/locales/or/common.json | 3 ++- src/components/center/DeleteCenterModal.tsx | 7 ++----- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/public/locales/en/common.json b/public/locales/en/common.json index fa71ff21..5293f591 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -290,7 +290,8 @@ "RENAME": "Rename", "CENTER_RENAMED": "Center Renamed Successfully!", "SEND_REQUEST":"Send Request", - "REQUEST_TO_DELETE_HAS_BEEN_SENT": "Request to Delete has been sent" + "REQUEST_TO_DELETE_HAS_BEEN_SENT": "Request to Delete has been sent", + "YOU_ARE_SENDING_REQUEST_TO_THE_STATE_ADMIN": "You are sending a request to the State Admin to delete this Center" }, "MANAGE_USERS": { "CENTERS_REQUESTED_SUCCESSFULLY": "Center Requested Successfully" diff --git a/public/locales/hi/common.json b/public/locales/hi/common.json index 36f1db5d..11216f45 100644 --- a/public/locales/hi/common.json +++ b/public/locales/hi/common.json @@ -269,6 +269,7 @@ "RENAME": "नाम बदलें", "CENTER_RENAMED": "केंद्र का नाम सफलतापूर्वक बदल दिया गया!", "SEND_REQUEST":"अनुरोध भेजें", - "REQUEST_TO_DELETE_HAS_BEEN_SENT": " हटाने का अनुरोध भेजा गया है" + "REQUEST_TO_DELETE_HAS_BEEN_SENT": " हटाने का अनुरोध भेजा गया है", + "YOU_ARE_SENDING_REQUEST_TO_THE_STATE_ADMIN": "आप राज्य प्रशासन को इस केंद्र को हटाने का अनुरोध भेज रहे हैं" } } diff --git a/public/locales/mr/common.json b/public/locales/mr/common.json index 8e03e238..176870db 100644 --- a/public/locales/mr/common.json +++ b/public/locales/mr/common.json @@ -270,6 +270,7 @@ "RENAME": "नाव बदला", "CENTER_RENAMED": "केंद्राचे नाव यशस्वीरित्या बदलले गेले!", "SEND_REQUEST":"विनंती पाठवा", - "REQUEST_TO_DELETE_HAS_BEEN_SENT": "हटवण्याची विनंती पाठवली आहे" + "REQUEST_TO_DELETE_HAS_BEEN_SENT": "हटवण्याची विनंती पाठवली आहे", + "YOU_ARE_SENDING_REQUEST_TO_THE_STATE_ADMIN": "आपण या केंद्राला हटविण्याचे विनंती राज्य प्रशासनाला पाठवत आहात" } } diff --git a/public/locales/or/common.json b/public/locales/or/common.json index e97aae8f..dd8068a1 100644 --- a/public/locales/or/common.json +++ b/public/locales/or/common.json @@ -214,7 +214,8 @@ "RENAME": "ପୁନ ame ନାମ କରନ୍ତୁ", "CENTER_RENAMED": "କେନ୍ଦ୍ରର ନାମ ସଫଳତାର ସହ ଚାଲିଛି!", "SEND_REQUEST":"ଅନୁରୋଧ ପଠାନ୍ତୁ", - "REQUEST_TO_DELETE_HAS_BEEN_SENT": "ହଟାଇବାକୁ ଅନୁରୋଧ ପଠାଯାଇଛି" + "REQUEST_TO_DELETE_HAS_BEEN_SENT": "ହଟାଇବାକୁ ଅନୁରୋଧ ପଠାଯାଇଛି", + "YOU_ARE_SENDING_REQUEST_TO_THE_STATE_ADMIN": "ଆପଣ ଏହି କେନ୍ଦ୍ରଟିକୁ ବିଲୋପ କରିବା ପାଇଁ ରାଜ୍ୟ ପ୍ରଶାସନକୁ ଅନୁରୋଧ ପଠାଉଛନ୍ତି" } } diff --git a/src/components/center/DeleteCenterModal.tsx b/src/components/center/DeleteCenterModal.tsx index 314a8f48..75d934c4 100644 --- a/src/components/center/DeleteCenterModal.tsx +++ b/src/components/center/DeleteCenterModal.tsx @@ -66,12 +66,9 @@ const DeleteCenterModal: React.FC = ({ transform: 'translate(-50%, -50%)', }} > - - - - - You are sending a request to the State Admin to delete this Center + + {t('CENTERS.YOU_ARE_SENDING_REQUEST_TO_THE_STATE_ADMIN')}