From 2cfbc8b54896a49a050254bb90d600e8eb26f8c6 Mon Sep 17 00:00:00 2001 From: TTPL-RT-52 Date: Wed, 17 Jul 2024 11:40:13 +0530 Subject: [PATCH 01/11] Issue #PS-1316 fix: Planned Sessions subject detail modal UI Implementation --- src/components/PlannedSession.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/PlannedSession.tsx b/src/components/PlannedSession.tsx index 4b054c65..1aec6cb4 100644 --- a/src/components/PlannedSession.tsx +++ b/src/components/PlannedSession.tsx @@ -173,7 +173,7 @@ const PlannedSession = () => { label="Start Time" value={date} onChange={handleChange} - sx={{ borderRadius: '4px' }} + sx={{ borderRadius: '4px', fontSize: '2px' }} /> From 45457e53e4b9e6507b21d2a87f1d7165a1d002dc Mon Sep 17 00:00:00 2001 From: TTPL-RT-52 Date: Wed, 17 Jul 2024 14:07:47 +0530 Subject: [PATCH 02/11] Issue #PS-1316 fix: Planned Sessions subject detail modal UI Implementation --- src/components/TopicDetails.tsx | 61 +++++++++++++++++++++++++++------ src/styles/customTheme.tsx | 2 ++ src/styles/globals.css | 15 ++++++++ 3 files changed, 68 insertions(+), 10 deletions(-) diff --git a/src/components/TopicDetails.tsx b/src/components/TopicDetails.tsx index a18ceb14..42653695 100644 --- a/src/components/TopicDetails.tsx +++ b/src/components/TopicDetails.tsx @@ -8,8 +8,8 @@ import { } from '@mui/material'; import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown'; +import CreateOutlinedIcon from '@mui/icons-material/CreateOutlined'; import DeleteOutlineIcon from '@mui/icons-material/DeleteOutline'; -import EditIcon from '@mui/icons-material/Edit'; import { useTheme } from '@mui/material/styles'; import { useTranslation } from 'next-i18next'; @@ -18,24 +18,43 @@ const TopicDetails = () => { const theme = useTheme(); return ( <> - + - {t('CENTER_SESSION.TOPIC')} - {/* Real Numbers */} + + {t('CENTER_SESSION.TOPIC')} + + + Real Numbers + - + - {t('CENTER_SESSION.SUBTOPIC')} - {/* Revisiting Irrational Numbers */} + + {t('CENTER_SESSION.SUBTOPIC')} + + + Revisiting Irrational Numbers + { m: 0, background: theme?.palette?.background.paper, px: '16px', + height: '10px !important', + '&.Mui-expanded': { + minHeight: '48px', + }, }} > { - {t('CENTER_SESSION.TITLE')} + + {t('CENTER_SESSION.TITLE')} + + + Video + - {t('CENTER_SESSION.TITLE')} + + {t('CENTER_SESSION.TITLE')} + + + Game + diff --git a/src/styles/customTheme.tsx b/src/styles/customTheme.tsx index 2b71fc39..a5c0ba79 100644 --- a/src/styles/customTheme.tsx +++ b/src/styles/customTheme.tsx @@ -49,12 +49,14 @@ const customTheme = extendTheme({ activeChannel: '#987100', selectedChannel: '#dba403', active: '#E2D9CC', + selected: '#FBF4E4', }, Skeleton: { bg: '#FFDCC2', }, background: { default: '#F3EDF7', + paper: '#F1E7D9', }, }, }, diff --git a/src/styles/globals.css b/src/styles/globals.css index aeae907a..47298d5f 100644 --- a/src/styles/globals.css +++ b/src/styles/globals.css @@ -946,3 +946,18 @@ main { .text-7C { color: var(--mui-palette-warning-400) !important; } + +.facilitator-bg { + background-image: url('./../assets/images/decorationBg.png'); + /* width: 140px; */ + height: 180px; + background-position: center; + background-size: cover; + background-repeat: no-repeat; + object-fit: cover; + border-radius: 28px; + display: flex; + flex-direction: column; + justify-content: end; + padding: 15px; +} From 92f3e5763dc3944b698c6bd826ef722ea58e6ac3 Mon Sep 17 00:00:00 2001 From: TTPL-RT-52 Date: Wed, 17 Jul 2024 14:12:24 +0530 Subject: [PATCH 03/11] Issue #PS-1316 fix: Planned Sessions subject detail modal UI Implementation --- src/styles/globals.css | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/styles/globals.css b/src/styles/globals.css index dd16f80c..a8a40c88 100644 --- a/src/styles/globals.css +++ b/src/styles/globals.css @@ -962,21 +962,6 @@ main { padding: 15px; } -.facilitator-bg { - background-image: url('./../assets/images/decorationBg.png'); - /* width: 140px; */ - height: 180px; - background-position: center; - background-size: cover; - background-repeat: no-repeat; - object-fit: cover; - border-radius: 28px; - display: flex; - flex-direction: column; - justify-content: end; - padding: 15px; -} - /* To Hide the caret icon on input type number */ input[type='number'] { -moz-appearance: textfield; From 59ee32b418412e26979c780cf54f441b17331a3a Mon Sep 17 00:00:00 2001 From: TTPL-RT-52 Date: Wed, 17 Jul 2024 16:29:18 +0530 Subject: [PATCH 04/11] Issue #PS-1333 fix: Select Topic Sub-topic modal UI Implementation --- package-lock.json | 9 ++++ package.json | 1 + src/components/SelectTopic.tsx | 92 ++++++++++++++++++++++++++++++++ src/pages/centers/[cohortId].tsx | 4 +- 4 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 src/components/SelectTopic.tsx diff --git a/package-lock.json b/package-lock.json index fe840624..76028d30 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,6 +26,7 @@ "i18next": "^23.11.4", "i18next-resources-to-backend": "^1.2.1", "jquery": "^3.7.1", + "moment": "^2.30.1", "next": "^14.2.3", "next-i18next": "^15.3.0", "next-pwa": "^5.6.0", @@ -12960,6 +12961,14 @@ "mkdirp": "bin/cmd.js" } }, + "node_modules/moment": { + "version": "2.30.1", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz", + "integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==", + "engines": { + "node": "*" + } + }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", diff --git a/package.json b/package.json index 008dec54..70a938af 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "i18next": "^23.11.4", "i18next-resources-to-backend": "^1.2.1", "jquery": "^3.7.1", + "moment": "^2.30.1", "next": "^14.2.3", "next-i18next": "^15.3.0", "next-pwa": "^5.6.0", diff --git a/src/components/SelectTopic.tsx b/src/components/SelectTopic.tsx new file mode 100644 index 00000000..713c4b70 --- /dev/null +++ b/src/components/SelectTopic.tsx @@ -0,0 +1,92 @@ +import { + Box, + Checkbox, + FormControl, + InputLabel, + ListItemText, + MenuItem, + Select, + SelectChangeEvent, +} from '@mui/material'; +import React, { ChangeEvent, useState } from 'react'; + +import { useTheme } from '@mui/material/styles'; +import { useTranslation } from 'next-i18next'; + +function SelectTopic() { + const { t } = useTranslation(); + const theme = useTheme(); + + const [selectedValues, setSelectedValues] = useState([]); + + const handleChange = (event: SelectChangeEvent) => { + const { + target: { value }, + } = event; + setSelectedValues(typeof value === 'string' ? value.split(',') : value); + }; + + return ( + + + + + Topic + + + + + + + + + Sub Topic + + + + + + ); +} + +export default SelectTopic; diff --git a/src/pages/centers/[cohortId].tsx b/src/pages/centers/[cohortId].tsx index df4785c6..7de89e19 100644 --- a/src/pages/centers/[cohortId].tsx +++ b/src/pages/centers/[cohortId].tsx @@ -23,6 +23,7 @@ import Header from '@/components/Header'; import KeyboardBackspaceOutlinedIcon from '@mui/icons-material/KeyboardBackspaceOutlined'; import ModeEditOutlineOutlinedIcon from '@mui/icons-material/ModeEditOutlineOutlined'; import MoreVertIcon from '@mui/icons-material/MoreVert'; +import PlannedSession from '@/components/PlannedSession'; import RenameCenterModal from '@/components/center/RenameCenterModal'; import Schedule from './../../components/Schedule'; import { Session } from '../../utils/Interfaces'; @@ -30,6 +31,7 @@ import SessionCard from '@/components/SessionCard'; import SessionCardFooter from '@/components/SessionCardFooter'; import Tab from '@mui/material/Tab'; import Tabs from '@mui/material/Tabs'; +import TopicDetails from '@/components/TopicDetails'; import WeekCalender from '@/components/WeekCalender'; import { getCohortDetails } from '@/services/CohortServices'; import { getSessions } from '@/services/Sessionservice'; @@ -283,7 +285,7 @@ const TeachingCenterDetails = () => { title={'Schedule'} primary={'Next'} > - + Date: Wed, 17 Jul 2024 16:44:11 +0530 Subject: [PATCH 05/11] Issue #PS-1333 fix: Select Topic Sub-topic modal UI Implementation --- package-lock.json | 8 -------- package.json | 1 - src/pages/centers/[cohortId].tsx | 3 ++- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 76028d30..c6a44b81 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12961,14 +12961,6 @@ "mkdirp": "bin/cmd.js" } }, - "node_modules/moment": { - "version": "2.30.1", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz", - "integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==", - "engines": { - "node": "*" - } - }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", diff --git a/package.json b/package.json index 70a938af..008dec54 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,6 @@ "i18next": "^23.11.4", "i18next-resources-to-backend": "^1.2.1", "jquery": "^3.7.1", - "moment": "^2.30.1", "next": "^14.2.3", "next-i18next": "^15.3.0", "next-pwa": "^5.6.0", diff --git a/src/pages/centers/[cohortId].tsx b/src/pages/centers/[cohortId].tsx index 7de89e19..d0478291 100644 --- a/src/pages/centers/[cohortId].tsx +++ b/src/pages/centers/[cohortId].tsx @@ -26,6 +26,7 @@ import MoreVertIcon from '@mui/icons-material/MoreVert'; import PlannedSession from '@/components/PlannedSession'; import RenameCenterModal from '@/components/center/RenameCenterModal'; import Schedule from './../../components/Schedule'; +import SelectTopic from '@/components/SelectTopic'; import { Session } from '../../utils/Interfaces'; import SessionCard from '@/components/SessionCard'; import SessionCardFooter from '@/components/SessionCardFooter'; @@ -285,7 +286,7 @@ const TeachingCenterDetails = () => { title={'Schedule'} primary={'Next'} > - + Date: Wed, 17 Jul 2024 16:45:11 +0530 Subject: [PATCH 06/11] Issue #PS-1333 fix: Select Topic Sub-topic modal UI Implementation --- package-lock.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index c6a44b81..fe840624 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,7 +26,6 @@ "i18next": "^23.11.4", "i18next-resources-to-backend": "^1.2.1", "jquery": "^3.7.1", - "moment": "^2.30.1", "next": "^14.2.3", "next-i18next": "^15.3.0", "next-pwa": "^5.6.0", From 941404e287308497b1519eb3594338e1022d134f Mon Sep 17 00:00:00 2001 From: Arif Date: Wed, 17 Jul 2024 16:48:45 +0530 Subject: [PATCH 07/11] Issue #PS-1282 feat: Implement the delete center --- public/locales/en/common.json | 5 +- public/locales/hi/common.json | 4 +- public/locales/mr/common.json | 4 +- public/locales/or/common.json | 4 +- src/components/DeleteUserModal.tsx | 11 +-- src/components/ManageUser.tsx | 76 ++++++++++++++----- src/components/RemoveFacilitatorAlert.tsx | 91 +++++++++++++++++++++++ src/store/manageUserStore.js | 2 +- 8 files changed, 164 insertions(+), 33 deletions(-) create mode 100644 src/components/RemoveFacilitatorAlert.tsx diff --git a/public/locales/en/common.json b/public/locales/en/common.json index e6adf58a..34000079 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -297,7 +297,9 @@ "CENTER_RENAMED": "Center Renamed Successfully!", "SEND_REQUEST": "Send Request", "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" + "YOU_ARE_SENDING_REQUEST_TO_THE_STATE_ADMIN": "You are sending a request to the State Admin to delete this Center", + "THE_USER_BELONGS_TO_THE_FOLLOWING_COHORT": "The user belongs to the following cohort: ", + "PLEASE_REMOVE_THE_USER_FROM_COHORT": "Please remove the user from these cohorts before proceeding with deletion." }, "CENTER_SESSION": { "THIS_SESSION": "This session", @@ -324,6 +326,7 @@ }, "MANAGE_USERS": { "CENTERS_REQUESTED_SUCCESSFULLY": "Center Requested Successfully" + }, "FORM": { "FULL_NAME":"Full Name", diff --git a/public/locales/hi/common.json b/public/locales/hi/common.json index 8832c891..eb63a2c0 100644 --- a/public/locales/hi/common.json +++ b/public/locales/hi/common.json @@ -273,7 +273,9 @@ "CENTER_RENAMED": "केंद्र का नाम सफलतापूर्वक बदल दिया गया!", "SEND_REQUEST": "अनुरोध भेजें", "REQUEST_TO_DELETE_HAS_BEEN_SENT": " हटाने का अनुरोध भेजा गया है", - "YOU_ARE_SENDING_REQUEST_TO_THE_STATE_ADMIN": "आप राज्य प्रशासन को इस केंद्र को हटाने का अनुरोध भेज रहे हैं" + "YOU_ARE_SENDING_REQUEST_TO_THE_STATE_ADMIN": "आप राज्य प्रशासन को इस केंद्र को हटाने का अनुरोध भेज रहे हैं", + "THE_USER_BELONGS_TO_THE_FOLLOWING_COHORT": "उपयोगकर्ता निम्नलिखित समूह का सदस्य है: ", + "PLEASE_REMOVE_THE_USER_FROM_COHORT": "कृपया हटाने से पहले उपयोगकर्ता को इन समूहों से हटा दें।" }, "CENTER_SESSION": { "THIS_SESSION": "यह सत्र", diff --git a/public/locales/mr/common.json b/public/locales/mr/common.json index 7ec42eff..77045c04 100644 --- a/public/locales/mr/common.json +++ b/public/locales/mr/common.json @@ -274,7 +274,9 @@ "CENTER_RENAMED": "केंद्राचे नाव यशस्वीरित्या बदलले गेले!", "SEND_REQUEST": "विनंती पाठवा", "REQUEST_TO_DELETE_HAS_BEEN_SENT": "हटवण्याची विनंती पाठवली आहे", - "YOU_ARE_SENDING_REQUEST_TO_THE_STATE_ADMIN": "आपण या केंद्राला हटविण्याचे विनंती राज्य प्रशासनाला पाठवत आहात" + "YOU_ARE_SENDING_REQUEST_TO_THE_STATE_ADMIN": "आपण या केंद्राला हटविण्याचे विनंती राज्य प्रशासनाला पाठवत आहात", + "THE_USER_BELONGS_TO_THE_FOLLOWING_COHORT": "वापरकर्ता खालील गटाचा सदस्य आहे: ", + "PLEASE_REMOVE_THE_USER_FROM_COHORT": "हटविण्यापूर्वी कृपया वापरकर्त्याला या गटांमधून काढून टाका।" }, "CENTER_SESSION": { "THIS_SESSION": "हे सत्र", diff --git a/public/locales/or/common.json b/public/locales/or/common.json index 08527dac..fd713ede 100644 --- a/public/locales/or/common.json +++ b/public/locales/or/common.json @@ -221,7 +221,9 @@ "CENTER_RENAMED": "କେନ୍ଦ୍ରର ନାମ ସଫଳତାର ସହ ଚାଲିଛି!", "SEND_REQUEST":"ଅନୁରୋଧ ପଠାନ୍ତୁ", "REQUEST_TO_DELETE_HAS_BEEN_SENT": "ହଟାଇବାକୁ ଅନୁରୋଧ ପଠାଯାଇଛି", - "YOU_ARE_SENDING_REQUEST_TO_THE_STATE_ADMIN": "ଆପଣ ଏହି କେନ୍ଦ୍ରଟିକୁ ବିଲୋପ କରିବା ପାଇଁ ରାଜ୍ୟ ପ୍ରଶାସନକୁ ଅନୁରୋଧ ପଠାଉଛନ୍ତି" + "YOU_ARE_SENDING_REQUEST_TO_THE_STATE_ADMIN": "ଆପଣ ଏହି କେନ୍ଦ୍ରଟିକୁ ବିଲୋପ କରିବା ପାଇଁ ରାଜ୍ୟ ପ୍ରଶାସନକୁ ଅନୁରୋଧ ପଠାଉଛନ୍ତି", + "THE_USER_BELONGS_TO_THE_FOLLOWING_COHORT": "ୟୁଜର ନିମ୍ନଲିଖିତ ସମୁହର ସଦସ୍ୟ: ", + "PLEASE_REMOVE_THE_USER_FROM_COHORT": "ଦୟାକରି ହଟାଇବା ପୂର୍ବରୁ ୟୁଜରକୁ ଏହି ସମୁହଗୁଡିକରୁ କାଢ଼ି ଦିଅନ୍ତୁ।" } } diff --git a/src/components/DeleteUserModal.tsx b/src/components/DeleteUserModal.tsx index 69d64b55..3eefe018 100644 --- a/src/components/DeleteUserModal.tsx +++ b/src/components/DeleteUserModal.tsx @@ -16,6 +16,8 @@ import { useTheme } from '@mui/material/styles'; import { useTranslation } from 'next-i18next'; import CloseIcon from '@mui/icons-material/Close'; import { showToastMessage } from './Toastify'; +import manageUserStore from '@/store/manageUserStore'; +import { getCohortList } from '@/services/CohortServices'; interface DeleteUserModalProps { open: boolean; @@ -23,6 +25,7 @@ interface DeleteUserModalProps { } const DeleteUserModal: React.FC = ({ open, onClose }) => { const { t } = useTranslation(); + const store = manageUserStore(); const theme = useTheme(); const style = { position: 'absolute', @@ -53,16 +56,8 @@ const DeleteUserModal: React.FC = ({ open, onClose }) => { }; const handleDeleteAction = () => { - - - - - // setOtherReason(''); setSelectedValue(''); - - - onClose(); showToastMessage(t('COMMON.USER_DELETED_PERMANENTLY'), 'success'); }; diff --git a/src/components/ManageUser.tsx b/src/components/ManageUser.tsx index 1d731bdc..39cddafe 100644 --- a/src/components/ManageUser.tsx +++ b/src/components/ManageUser.tsx @@ -43,6 +43,7 @@ import { getMyUserList } from '@/services/MyClassDetailsService'; import DeleteUserModal from './DeleteUserModal'; import Image from 'next/image'; import profileALT from '../assets/images/Profile.png'; +import RemoveFacilitatorAlert from './RemoveFacilitatorAlert'; interface Cohort { cohortId: string; parentId: string; @@ -82,7 +83,7 @@ const manageUsers: React.FC = ({ const { t } = useTranslation(); const theme = useTheme(); const router = useRouter(); -const store = manageUserStore(); + const store = manageUserStore(); const [value, setValue] = React.useState(1); const [users, setUsers] = useState< { @@ -112,13 +113,14 @@ const store = manageUserStore(); const [reassignBlockRequestModalOpen, setReassignBlockRequestModalOpen] = React.useState(false); const [openDeleteUserModal, setOpenDeleteUserModal] = React.useState(false); - + const [openRemoveUserModal, setOpenRemoveUserModal] = React.useState(false); + const [removeCohortNames, setRemoveCohortNames] = React.useState(''); const CustomLink = styled(Link)(({ theme }) => ({ textDecoration: 'underline', textDecorationColor: theme?.palette?.secondary.main, textDecorationThickness: '1px', })); - const setDeleteId = manageUserStore((state) => state.setDeleteId); + const setCohortDeleteId = manageUserStore((state) => state.setCohortDeleteId); useEffect(() => { const getFacilitator = async () => { @@ -148,22 +150,26 @@ const store = manageUserStore(); return; } const userIds = facilitatorList.map((user: any) => user.userId); - const cohortDetailsPromises = userIds.map((userId: string) => + const cohortDetailsPromises = userIds.map((userId: string) => getCohortList(userId, { filter: 'true' }) ); const cohortDetails = await Promise.all(cohortDetailsPromises); console.log('Cohort Details:', cohortDetails); - - const extractedData = facilitatorList.map((user: any, index: number) => { - const cohorts = cohortDetails[index] || []; - const cohortNames = cohorts.map((cohort: any) => cohort.cohortName).join(', '); - - return { - userId: user.userId, - name: user.name, - cohortNames: cohortNames || null, - }; - }); + + const extractedData = facilitatorList.map( + (user: any, index: number) => { + const cohorts = cohortDetails[index] || []; + const cohortNames = cohorts + .map((cohort: any) => cohort.cohortName) + .join(', '); + + return { + userId: user.userId, + name: user.name, + cohortNames: cohortNames || null, + }; + } + ); setTimeout(() => { setUsers(extractedData); }); @@ -244,10 +250,15 @@ const store = manageUserStore(); setState({ ...state, bottom: false }); }; + const handleCloseRemoveModal = () => { + setOpenRemoveUserModal(false); + + }; + const toggleDrawer = (anchor: Anchor, open: boolean, user: any) => (event: React.KeyboardEvent | React.MouseEvent) => { - setDeleteId(user.userId); + setCohortDeleteId(user.userId); setCenters( cohortsData?.[user.userId]?.map((cohort) => cohort.name) || [] ); @@ -266,7 +277,23 @@ const store = manageUserStore(); const listItemClick = async (event: React.MouseEvent, name: string) => { if (name === 'delete-User') { - setOpenDeleteUserModal(true); + const userId = store.deleteId; + console.log(userId); + + const cohortList = await getCohortList(userId); + console.log('Cohort List:', cohortList); + + if (cohortList && cohortList.length > 0) { + const cohortNames = cohortList + .map((cohort: { cohortName: any }) => cohort.cohortName) + .join(', '); + setOpenRemoveUserModal(true); + setRemoveCohortNames(cohortNames) + } else { + console.log('User does not belong to any cohorts, proceed with deletion'); + setOpenDeleteUserModal(true); + } + // const name = selectedUser?.name || ''; // const userId = selectedUser?.userId || ''; @@ -565,11 +592,13 @@ const store = manageUserStore(); borderRadius: '5px', fontSize: '12px', fontWeight: '600', - color: 'black', - marginBottom: '10px', + color: 'black', + marginBottom: '10px', }} > - {user?.cohortNames ? `${user.cohortNames}` : 'N/A'} + {user?.cohortNames + ? `${user.cohortNames}` + : 'N/A'} @@ -704,6 +733,13 @@ const store = manageUserStore(); open={openDeleteUserModal} onClose={handleCloseModal} /> + + + )} diff --git a/src/components/RemoveFacilitatorAlert.tsx b/src/components/RemoveFacilitatorAlert.tsx new file mode 100644 index 00000000..518d2388 --- /dev/null +++ b/src/components/RemoveFacilitatorAlert.tsx @@ -0,0 +1,91 @@ +import { + Box, + Button, + Divider, + FormControl, + FormControlLabel, + InputLabel, + Modal, + Radio, + RadioGroup, + TextField, + Typography, + } from '@mui/material'; + import React, { useState } from 'react'; + import { useTheme } from '@mui/material/styles'; + import { useTranslation } from 'next-i18next'; + import CloseIcon from '@mui/icons-material/Close'; + import { showToastMessage } from './Toastify'; + import manageUserStore from '@/store/manageUserStore'; + import { getCohortList } from '@/services/CohortServices'; + + interface RemoveFacilitatorAlertProps { + removeCohortNames : string; + open: boolean; + onClose: () => void; + } + const RemoveFacilitatorAlert: React.FC = ({removeCohortNames, open, onClose }) => { + const { t } = useTranslation(); + const store = manageUserStore(); + const theme = useTheme(); + const style = { + padding : "20px", + position: 'absolute', + top: '50%', + left: '50%', + transform: 'translate(-50%, -50%)', + width: '85%', + boxShadow: 24, + bgcolor: '#fff', + borderRadius: '16px', + '@media (min-width: 600px)': { + width: '450px', + }, + }; + + return ( + + + + + + {t('COMMON.DELETE_USER')} + + + + + + + + {t('CENTERS.THE_USER_BELONGS_TO_THE_FOLLOWING_COHORT')} {removeCohortNames}. {t('CENTERS.PLEASE_REMOVE_THE_USER_FROM_COHORT')} + + + + + + ); + }; + + export default RemoveFacilitatorAlert; + \ No newline at end of file diff --git a/src/store/manageUserStore.js b/src/store/manageUserStore.js index dc46454d..576f1dc2 100644 --- a/src/store/manageUserStore.js +++ b/src/store/manageUserStore.js @@ -5,7 +5,7 @@ const manageUserStore = create( persist( (set) => ({ deleteId: '', - setDeleteId: (newDeleteId) => set((state) => ({ deleteId: newDeleteId })), + setCohortDeleteId: (newCohortDeleteId) => set((state) => ({ deleteId: newCohortDeleteId })), }), { name: 'teacherApp', From b6f4be0646da259db5f164794f8e8a674d6ceb23 Mon Sep 17 00:00:00 2001 From: TTPL-RT-52 Date: Wed, 17 Jul 2024 16:52:56 +0530 Subject: [PATCH 08/11] Issue #PS-1333 fix: Select Topic Sub-topic modal UI Implementation --- src/components/SelectTopic.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/SelectTopic.tsx b/src/components/SelectTopic.tsx index 713c4b70..012572f3 100644 --- a/src/components/SelectTopic.tsx +++ b/src/components/SelectTopic.tsx @@ -33,12 +33,12 @@ function SelectTopic() { - Topic + {t('CENTER_SESSION.TOPIC')} Date: Wed, 17 Jul 2024 17:01:55 +0530 Subject: [PATCH 09/11] Issue #PS-1333 fix: Select Topic Sub-topic modal UI Implementation --- src/components/TopicDetails.tsx | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/components/TopicDetails.tsx b/src/components/TopicDetails.tsx index 42653695..71c64bed 100644 --- a/src/components/TopicDetails.tsx +++ b/src/components/TopicDetails.tsx @@ -120,28 +120,44 @@ const TopicDetails = () => { {t('CENTER_SESSION.TITLE')} - Video + Video {/* will came from API */} {t('CENTER_SESSION.TITLE')} - Game + Game {/* will came from API */} From 6453193632e730e59aaff37ad666fbe106c98a17 Mon Sep 17 00:00:00 2001 From: TTPL-RT-52 Date: Wed, 17 Jul 2024 17:03:31 +0530 Subject: [PATCH 10/11] Issue #PS-1333 fix: Select Topic Sub-topic modal UI Implementation --- src/components/TopicDetails.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/TopicDetails.tsx b/src/components/TopicDetails.tsx index 71c64bed..730be612 100644 --- a/src/components/TopicDetails.tsx +++ b/src/components/TopicDetails.tsx @@ -36,7 +36,7 @@ const TopicDetails = () => { - Real Numbers + Real Numbers {/* will came from API */} @@ -53,7 +53,7 @@ const TopicDetails = () => { {t('CENTER_SESSION.SUBTOPIC')} - Revisiting Irrational Numbers + Revisiting Irrational Numbers {/* will came from API */} From 0896654fc0f7cfd86d28132a7cb7332af0b1d6f5 Mon Sep 17 00:00:00 2001 From: Arif Date: Wed, 17 Jul 2024 17:18:54 +0530 Subject: [PATCH 11/11] Issue #PS-1282 feat: Implement the delete center --- src/components/ManageUser.tsx | 37 +++--- src/components/RemoveFacilitatorAlert.tsx | 91 -------------- src/components/SimpleModal.tsx | 140 ++++++++++++++++++++++ 3 files changed, 163 insertions(+), 105 deletions(-) delete mode 100644 src/components/RemoveFacilitatorAlert.tsx create mode 100644 src/components/SimpleModal.tsx diff --git a/src/components/ManageUser.tsx b/src/components/ManageUser.tsx index 39cddafe..d7717291 100644 --- a/src/components/ManageUser.tsx +++ b/src/components/ManageUser.tsx @@ -43,7 +43,8 @@ import { getMyUserList } from '@/services/MyClassDetailsService'; import DeleteUserModal from './DeleteUserModal'; import Image from 'next/image'; import profileALT from '../assets/images/Profile.png'; -import RemoveFacilitatorAlert from './RemoveFacilitatorAlert'; +import RemoveFacilitatorAlert from './SimpleModal'; +import SimpleModal from './SimpleModal'; interface Cohort { cohortId: string; parentId: string; @@ -252,7 +253,6 @@ const manageUsers: React.FC = ({ const handleCloseRemoveModal = () => { setOpenRemoveUserModal(false); - }; const toggleDrawer = @@ -279,21 +279,22 @@ const manageUsers: React.FC = ({ if (name === 'delete-User') { const userId = store.deleteId; console.log(userId); - + const cohortList = await getCohortList(userId); console.log('Cohort List:', cohortList); - + if (cohortList && cohortList.length > 0) { const cohortNames = cohortList .map((cohort: { cohortName: any }) => cohort.cohortName) .join(', '); setOpenRemoveUserModal(true); - setRemoveCohortNames(cohortNames) + setRemoveCohortNames(cohortNames); } else { - console.log('User does not belong to any cohorts, proceed with deletion'); + console.log( + 'User does not belong to any cohorts, proceed with deletion' + ); setOpenDeleteUserModal(true); } - // const name = selectedUser?.name || ''; // const userId = selectedUser?.userId || ''; @@ -733,13 +734,21 @@ const manageUsers: React.FC = ({ open={openDeleteUserModal} onClose={handleCloseModal} /> - - - + + {' '} + + + {t('CENTERS.THE_USER_BELONGS_TO_THE_FOLLOWING_COHORT')}{' '} + {removeCohortNames}.{' '} + {t('CENTERS.PLEASE_REMOVE_THE_USER_FROM_COHORT')} + + + )} diff --git a/src/components/RemoveFacilitatorAlert.tsx b/src/components/RemoveFacilitatorAlert.tsx deleted file mode 100644 index 518d2388..00000000 --- a/src/components/RemoveFacilitatorAlert.tsx +++ /dev/null @@ -1,91 +0,0 @@ -import { - Box, - Button, - Divider, - FormControl, - FormControlLabel, - InputLabel, - Modal, - Radio, - RadioGroup, - TextField, - Typography, - } from '@mui/material'; - import React, { useState } from 'react'; - import { useTheme } from '@mui/material/styles'; - import { useTranslation } from 'next-i18next'; - import CloseIcon from '@mui/icons-material/Close'; - import { showToastMessage } from './Toastify'; - import manageUserStore from '@/store/manageUserStore'; - import { getCohortList } from '@/services/CohortServices'; - - interface RemoveFacilitatorAlertProps { - removeCohortNames : string; - open: boolean; - onClose: () => void; - } - const RemoveFacilitatorAlert: React.FC = ({removeCohortNames, open, onClose }) => { - const { t } = useTranslation(); - const store = manageUserStore(); - const theme = useTheme(); - const style = { - padding : "20px", - position: 'absolute', - top: '50%', - left: '50%', - transform: 'translate(-50%, -50%)', - width: '85%', - boxShadow: 24, - bgcolor: '#fff', - borderRadius: '16px', - '@media (min-width: 600px)': { - width: '450px', - }, - }; - - return ( - - - - - - {t('COMMON.DELETE_USER')} - - - - - - - - {t('CENTERS.THE_USER_BELONGS_TO_THE_FOLLOWING_COHORT')} {removeCohortNames}. {t('CENTERS.PLEASE_REMOVE_THE_USER_FROM_COHORT')} - - - - - - ); - }; - - export default RemoveFacilitatorAlert; - \ No newline at end of file diff --git a/src/components/SimpleModal.tsx b/src/components/SimpleModal.tsx new file mode 100644 index 00000000..e2575ae8 --- /dev/null +++ b/src/components/SimpleModal.tsx @@ -0,0 +1,140 @@ +import { + Box, + Button, + Divider, + FormControl, + FormControlLabel, + InputLabel, + Modal, + Radio, + RadioGroup, + TextField, + Typography, +} from '@mui/material'; +import React, { ReactNode, useState } from 'react'; +import { useTheme } from '@mui/material/styles'; +import { useTranslation } from 'next-i18next'; +import CloseIcon from '@mui/icons-material/Close'; +import { showToastMessage } from './Toastify'; +import manageUserStore from '@/store/manageUserStore'; +import { getCohortList } from '@/services/CohortServices'; + +interface SimpleModalProps { + secondaryActionHandler?: () => void; + primaryActionHandler: () => void; + secondaryText?: string; + primaryText: string; + children: ReactNode; + open: boolean; + onClose: () => void; +} +const SimpleModal: React.FC = ({ + open, + onClose, + primaryText, + secondaryText, + primaryActionHandler, + secondaryActionHandler, + children, +}) => { + const { t } = useTranslation(); + const store = manageUserStore(); + const theme = useTheme(); + const style = { + padding: '20px', + position: 'absolute', + top: '50%', + left: '50%', + transform: 'translate(-50%, -50%)', + width: '85%', + boxShadow: 24, + bgcolor: '#fff', + borderRadius: '16px', + '@media (min-width: 600px)': { + width: '450px', + }, + }; + + return ( + + + + + + {t('COMMON.DELETE_USER')} + + + + + + {children} + + + + {primaryText && ( + + )} + + {secondaryText && ( + + )} + + + + ); +}; + +export default SimpleModal;