From 9961e68b28bbd00e7ea5beeef239682738c3eef2 Mon Sep 17 00:00:00 2001 From: Arif Date: Thu, 18 Jul 2024 18:17:30 +0530 Subject: [PATCH] Issue #PS-1282 feat: Implement the delete learner --- src/components/CohortFacilitatorList.tsx | 2 +- src/components/CohortLearnerList.tsx | 4 ++-- src/components/DeleteUserModal.tsx | 6 +++--- .../{LearnersList.tsx => LearnersListItem.tsx} | 12 +++++++++--- src/components/ManageUser.tsx | 8 ++++---- src/pages/learner/[userId].tsx | 2 ++ 6 files changed, 21 insertions(+), 13 deletions(-) rename src/components/{LearnersList.tsx => LearnersListItem.tsx} (98%) diff --git a/src/components/CohortFacilitatorList.tsx b/src/components/CohortFacilitatorList.tsx index 17e80256..7efd6005 100644 --- a/src/components/CohortFacilitatorList.tsx +++ b/src/components/CohortFacilitatorList.tsx @@ -5,7 +5,7 @@ import { getFieldValue, toPascalCase, } from '@/utils/Helper'; -import LearnersList from '@/components/LearnersList'; +import LearnersList from '@/components/LearnersListItem'; import { Status, limit } from '@/utils/app.constant'; import { showToastMessage } from './Toastify'; import { useTranslation } from 'next-i18next'; diff --git a/src/components/CohortLearnerList.tsx b/src/components/CohortLearnerList.tsx index 4534aa6a..047b6b76 100644 --- a/src/components/CohortLearnerList.tsx +++ b/src/components/CohortLearnerList.tsx @@ -5,7 +5,7 @@ import { getFieldValue, toPascalCase, } from '@/utils/Helper'; -import LearnersList from '@/components/LearnersList'; +import LearnersListItem from '@/components/LearnersListItem'; import { Status, limit } from '@/utils/app.constant'; import { showToastMessage } from './Toastify'; import { useTranslation } from 'next-i18next'; @@ -84,7 +84,7 @@ const CohortLearnerList: React.FC = ({ <> {userData?.map((data: any) => { return ( - void; } const DeleteUserModal: React.FC = ({ - deleteFacilitatorId, + userId, open, onClose, }) => { @@ -67,7 +67,7 @@ const DeleteUserModal: React.FC = ({ reason: selectedValue, }; - const response = await updateFacilitator(deleteFacilitatorId, userData); + const response = await updateFacilitator(userId, userData); console.log(response); diff --git a/src/components/LearnersList.tsx b/src/components/LearnersListItem.tsx similarity index 98% rename from src/components/LearnersList.tsx rename to src/components/LearnersListItem.tsx index 8834aee4..7d67aeed 100644 --- a/src/components/LearnersList.tsx +++ b/src/components/LearnersListItem.tsx @@ -30,12 +30,13 @@ import { updateCohortMemberStatus } from '@/services/MyClassDetailsService'; // import Woman2Icon from '@mui/icons-material/Woman2'; import { useTheme } from '@mui/material/styles'; import { useTranslation } from 'next-i18next'; +import { useRouter } from 'next/router'; type Anchor = 'bottom'; const centerList = ['Nashik', 'Shirdi', 'kamptee']; const centers = ['shirdi']; -const LearnersList: React.FC = ({ +const LearnersListItem: React.FC = ({ userId, learnerName, isDropout, @@ -58,6 +59,9 @@ const LearnersList: React.FC = ({ setConfirmationModalReassignCentersOpen, ] = React.useState(false); + console.log(userId); + + const [learnerState, setLearnerState] = React.useState({ loading: false, isModalOpenLearner: false, @@ -68,6 +72,8 @@ const LearnersList: React.FC = ({ }); const theme = useTheme(); + const router = useRouter(); + const { learnerId }: any = router.query; const { t } = useTranslation(); const [openCentersModal, setOpenCentersModal] = React.useState(false); const [openDeleteUserModal, setOpenDeleteUserModal] = React.useState(false); @@ -616,9 +622,9 @@ const LearnersList: React.FC = ({ isForLearner={true} /> - + ); }; -export default LearnersList; +export default LearnersListItem; diff --git a/src/components/ManageUser.tsx b/src/components/ManageUser.tsx index 01265716..e692f995 100644 --- a/src/components/ManageUser.tsx +++ b/src/components/ManageUser.tsx @@ -34,7 +34,7 @@ import { editEditUser } from '@/services/ProfileService'; import ConfirmationModal from '@/components/ConfirmationModal'; import { Status } from '@/utils/app.constant'; import AddIcon from '@mui/icons-material/Add'; -import LearnersList from '@/components/LearnersList'; +import LearnersList from '@/components/LearnersListItem'; import Link from 'next/link'; import { styled } from '@mui/system'; import manageUserStore from '../store/manageUserStore'; @@ -116,7 +116,7 @@ const manageUsers: React.FC = ({ const [openDeleteUserModal, setOpenDeleteUserModal] = React.useState(false); const [openRemoveUserModal, setOpenRemoveUserModal] = React.useState(false); const [removeCohortNames, setRemoveCohortNames] = React.useState(''); - const [deleteFacilitatorId, setDeleteFacilitatorId] = React.useState(''); + const [userId, setUserId] = React.useState(''); const CustomLink = styled(Link)(({ theme }) => ({ textDecoration: 'underline', textDecorationColor: theme?.palette?.secondary.main, @@ -303,7 +303,7 @@ const manageUsers: React.FC = ({ const listItemClick = async (event: React.MouseEvent, name: string) => { if (name === 'delete-User') { const userId = store?.deleteId; - setDeleteFacilitatorId(userId); + setUserId(userId); const cohortList = await getCohortList(userId); console.log('Cohort List:', cohortList); @@ -757,7 +757,7 @@ const manageUsers: React.FC = ({ /> diff --git a/src/pages/learner/[userId].tsx b/src/pages/learner/[userId].tsx index 34c8a021..63db5e17 100644 --- a/src/pages/learner/[userId].tsx +++ b/src/pages/learner/[userId].tsx @@ -664,6 +664,8 @@ const LearnerProfile: React.FC = () => { const userDetails = data; try { if (userId) { + console.log("HELLO"); + const response = await editEditUser(user_id, userDetails); ReactGA.event('edit-learner-profile-successful', { userId: userId });