Skip to content

Commit

Permalink
Issue #PS-1282 feat: Implement the delete learner
Browse files Browse the repository at this point in the history
  • Loading branch information
Aar-if committed Jul 18, 2024
1 parent cf5b87a commit 9961e68
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/components/CohortFacilitatorList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions src/components/CohortLearnerList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -84,7 +84,7 @@ const CohortLearnerList: React.FC<CohortLearnerListProp> = ({
<>
{userData?.map((data: any) => {
return (
<LearnersList
<LearnersListItem
key={data.userId}
userId={data.userId}
learnerName={data.name}
Expand Down
6 changes: 3 additions & 3 deletions src/components/DeleteUserModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import { getCohortList } from '@/services/CohortServices';
import { updateFacilitator } from '@/services/ManageUser';

interface DeleteUserModalProps {
deleteFacilitatorId: string;
userId: string;
open: boolean;
onClose: () => void;
}
const DeleteUserModal: React.FC<DeleteUserModalProps> = ({
deleteFacilitatorId,
userId,
open,
onClose,
}) => {
Expand Down Expand Up @@ -67,7 +67,7 @@ const DeleteUserModal: React.FC<DeleteUserModalProps> = ({
reason: selectedValue,
};

const response = await updateFacilitator(deleteFacilitatorId, userData);
const response = await updateFacilitator(userId, userData);

console.log(response);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<LearnerListProps> = ({
const LearnersListItem: React.FC<LearnerListProps> = ({
userId,
learnerName,
isDropout,
Expand All @@ -58,6 +59,9 @@ const LearnersList: React.FC<LearnerListProps> = ({
setConfirmationModalReassignCentersOpen,
] = React.useState<boolean>(false);

console.log(userId);


const [learnerState, setLearnerState] = React.useState({
loading: false,
isModalOpenLearner: false,
Expand All @@ -68,6 +72,8 @@ const LearnersList: React.FC<LearnerListProps> = ({
});

const theme = useTheme<any>();
const router = useRouter();
const { learnerId }: any = router.query;
const { t } = useTranslation();
const [openCentersModal, setOpenCentersModal] = React.useState(false);
const [openDeleteUserModal, setOpenDeleteUserModal] = React.useState(false);
Expand Down Expand Up @@ -616,9 +622,9 @@ const LearnersList: React.FC<LearnerListProps> = ({
isForLearner={true}
/>

<DeleteUserModal open={openDeleteUserModal} onClose={handleCloseModal} />
<DeleteUserModal userId={userId} open={openDeleteUserModal} onClose={handleCloseModal} />
</>
);
};

export default LearnersList;
export default LearnersListItem;
8 changes: 4 additions & 4 deletions src/components/ManageUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -116,7 +116,7 @@ const manageUsers: React.FC<ManageUsersProps> = ({
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,
Expand Down Expand Up @@ -303,7 +303,7 @@ const manageUsers: React.FC<ManageUsersProps> = ({
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);
Expand Down Expand Up @@ -757,7 +757,7 @@ const manageUsers: React.FC<ManageUsersProps> = ({
/>

<DeleteUserModal
deleteFacilitatorId={deleteFacilitatorId}
userId={userId}
open={openDeleteUserModal}
onClose={handleCloseModal}
/>
Expand Down
2 changes: 2 additions & 0 deletions src/pages/learner/[userId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 });

Expand Down

0 comments on commit 9961e68

Please sign in to comment.