From f81faabe7ad0f08acfb3a09fbf95a846ceda7b8a Mon Sep 17 00:00:00 2001 From: upendraTekdi Date: Tue, 20 Aug 2024 14:22:36 +0530 Subject: [PATCH] Task #224976: removed dropout and reassign center from learner list , name change instead of delete permanantely to remove user from class , fix issue of getting undefiend value to show below of classname on my teaching center,remove assesment report from learner profile , center sessions removed , add langs const for mother name and whatsapp access on create learner form , handle error when login and no cohort --- app.config.ts | 3 + public/locales/en/common.json | 6 +- src/components/CohortSelectionSection.tsx | 7 +- src/components/LearnersListItem.tsx | 210 +++++++++++----------- src/pages/centers/[cohortId].tsx | 10 +- src/pages/centers/[cohortId]/index.tsx | 16 +- src/pages/learner/[userId].tsx | 31 ++-- 7 files changed, 150 insertions(+), 133 deletions(-) diff --git a/app.config.ts b/app.config.ts index 2822b60f..cb9933db 100644 --- a/app.config.ts +++ b/app.config.ts @@ -78,3 +78,6 @@ export const ShowManageUsers = false; //mark attendance model export const ShowSelfAttendance = true; + +export const reassignCenters = false; +export const markdDropOut = false; diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 9975274a..66ca9fe0 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -96,6 +96,7 @@ "LEARNER_REMOVED": "Learner has been removed", "DROPPED_OUT": "Dropped Out", "DELETE_USER": "Delete User Permanently", + "REMOVE_USER_FROM_CLASS": "Remove user from class", "DELETE_USER_WITH_REASON": "Delete User", "USER_DELETED_PERMANENTLY": "User Successfully Deleted!", "OBSERVATIONS_FORMS": "Observations and Forms", @@ -374,7 +375,6 @@ "MANAGE_USERS": { "CENTERS_REQUESTED_SUCCESSFULLY": "Center Requested Successfully", "CENTERS_REQUEST_FAILED": "Center Requested Failed" - }, "FORM": { "FULL_NAME": "Full Name", @@ -451,7 +451,9 @@ "DROP_OUT_REASON": "Reason for Drop Out From School", "ASSIGN_CENTERS": "Assign Centers", "TYPE_OF_COHORT": "Type of cohort", - "NOTE_THIS_WILL_BE_CENTER_NAME": "Note this will be Center name" + "NOTE_THIS_WILL_BE_CENTER_NAME": "Note this will be Center name", + "ACCESS_TO_WHATSAPP": "Access To WhatsApp", + "MOTHER_NAME": "Mother's Name" }, "FORM_ERROR_MESSAGES": { "INVALID_INPUT": "Invalid Input.", diff --git a/src/components/CohortSelectionSection.tsx b/src/components/CohortSelectionSection.tsx index dddb4114..668bf340 100644 --- a/src/components/CohortSelectionSection.tsx +++ b/src/components/CohortSelectionSection.tsx @@ -131,15 +131,15 @@ const CohortSelectionSection: React.FC = ({ customField: 'true', }); console.log('Response:', response); - const cohortData = response[0]; + const cohortData = response ? response[0] : []; if (cohortData?.customField?.length) { - const district = cohortData.customField.find( + const district = cohortData?.customField.find( (item: CustomField) => item.label === 'DISTRICTS' ); setDistrictCode(district?.code); setDistrictId(district?.fieldId); - const state = cohortData.customField.find( + const state = cohortData?.customField.find( (item: CustomField) => item.label === 'STATES' ); setStateCode(state?.code); @@ -261,6 +261,7 @@ const CohortSelectionSection: React.FC = ({ setLoading(false); } catch (error) { console.error('Error fetching cohort list', error); + console.log('error', error); setLoading(false); showToastMessage(t('COMMON.SOMETHING_WENT_WRONG'), 'error'); } diff --git a/src/components/LearnersListItem.tsx b/src/components/LearnersListItem.tsx index 7e319287..cc4e7a06 100644 --- a/src/components/LearnersListItem.tsx +++ b/src/components/LearnersListItem.tsx @@ -54,7 +54,7 @@ const LearnersListItem: React.FC = ({ center, showMiniProfile, onLearnerDelete, - isFromProfile = false + isFromProfile = false, }) => { const [state, setState] = React.useState({ bottom: false, @@ -119,20 +119,20 @@ const LearnersListItem: React.FC = ({ const toggleDrawer = (anchor: Anchor, open: boolean) => - (event: React.KeyboardEvent | React.MouseEvent) => { - setCohortLearnerDeleteId(cohortMembershipId); - setReassignId(userId); - - if ( - event.type === 'keydown' && - ((event as React.KeyboardEvent).key === 'Tab' || - (event as React.KeyboardEvent).key === 'Shift') - ) { - return; - } + (event: React.KeyboardEvent | React.MouseEvent) => { + setCohortLearnerDeleteId(cohortMembershipId); + setReassignId(userId); + + if ( + event.type === 'keydown' && + ((event as React.KeyboardEvent).key === 'Tab' || + (event as React.KeyboardEvent).key === 'Shift') + ) { + return; + } - setState({ ...state, bottom: open }); - }; + setState({ ...state, bottom: open }); + }; const setLoading = (loading: boolean) => { setLearnerState((prevState) => ({ ...prevState, loading })); @@ -190,7 +190,7 @@ const LearnersListItem: React.FC = ({ }); throw new Error( response.params?.errmsg || - 'An error occurred while updating the user.' + 'An error occurred while updating the user.' ); } else { ReactGA.event('unmark-dropout-student-successful', { @@ -242,7 +242,7 @@ const LearnersListItem: React.FC = ({ }); throw new Error( response.params?.errmsg || - 'An error occurred while updating the user.' + 'An error occurred while updating the user.' ); } else { ReactGA.event('remove-student-successful', { @@ -320,7 +320,7 @@ const LearnersListItem: React.FC = ({ const filteredFields = filterMiniProfileFields(learnerState.customFieldsData); - const getTeamLeadersCenters = async () => { }; + const getTeamLeadersCenters = async () => {}; const handleCloseCentersModal = () => { setOpenCentersModal(false); @@ -389,8 +389,6 @@ const LearnersListItem: React.FC = ({ return null; }; - - const handleUserDelete = () => { setIsUserDeleted(true); onLearnerDelete(); @@ -427,8 +425,8 @@ const LearnersListItem: React.FC = ({ borderBottom: `1px solid ${theme.palette.warning['A100']}`, }, '@media (min-width: 900px)': { - marginTop: '20px' - } + marginTop: '20px', + }, }} > = ({ border: `1px solid ${theme.palette.warning['A100']}`, padding: '10px', borderRadius: '8px', - background: theme.palette.warning['A400'] + background: theme.palette.warning['A400'], }, }} > @@ -575,11 +573,11 @@ const LearnersListItem: React.FC = ({ - - { - isMobile ? toggleDrawer('bottom', true)(event) : handleMenuOpen(event) + isMobile + ? toggleDrawer('bottom', true)(event) + : handleMenuOpen(event); }} sx={{ fontSize: isMobile ? '24px' : 'inherit', @@ -602,86 +600,90 @@ const LearnersListItem: React.FC = ({ optionList={ block ? [ - { - label: t('COMMON.REASSIGN_BLOCKS_REQUEST'), - icon: ( - - ), - name: 'reassign-block-request', - }, - { - label: t('COMMON.REASSIGN_CENTERS'), - icon: ( - - ), - name: 'reassign-centers', - }, - { - label: isDropout - ? t('COMMON.UNMARK_DROP_OUT') - : t('COMMON.MARK_DROP_OUT'), - icon: ( - - ), - name: isDropout ? 'unmark-drop-out' : 'mark-drop-out', - }, - { - label: t('COMMON.DELETE_USER'), - icon: ( - - ), - name: 'delete-User', - }, - ].filter( - (option) => - type == Role.STUDENT || - (option.name !== 'mark-drop-out' && - option.name !== 'unmark-drop-out') - ) + // { + // label: t('COMMON.REASSIGN_BLOCKS_REQUEST'), + // icon: ( + // + // ), + // name: 'reassign-block-request', + // }, + + // { + // label: t('COMMON.REASSIGN_CENTERS'), + // icon: ( + // + // ), + // name: 'reassign-centers', + // }, + + // { + // label: isDropout + // ? t('COMMON.UNMARK_DROP_OUT') + // : t('COMMON.MARK_DROP_OUT'), + // icon: ( + // + // ), + // name: isDropout ? 'unmark-drop-out' : 'mark-drop-out', + // }, + + { + label: t('COMMON.REMOVE_USER_FROM_CLASS'), + icon: ( + + ), + name: 'delete-User', + }, + ].filter( + (option) => + type == Role.STUDENT || + (option.name !== 'mark-drop-out' && + option.name !== 'unmark-drop-out') + ) : [ - { - label: t('COMMON.REASSIGN_CENTERS'), - icon: ( - - ), - name: 'reassign-centers', - }, - { - label: isDropout - ? t('COMMON.UNMARK_DROP_OUT') - : t('COMMON.MARK_DROP_OUT'), - icon: ( - - ), - name: isDropout ? 'unmark-drop-out' : 'mark-drop-out', - }, - { - label: t('COMMON.DELETE_USER'), - icon: ( - - ), - name: 'delete-User', - }, - ].filter( - (option) => - type == Role.STUDENT || - (option.name !== 'mark-drop-out' && - option.name !== 'unmark-drop-out') - ) + // { + // label: t('COMMON.REASSIGN_CENTERS'), + // icon: ( + // + // ), + // name: 'reassign-centers', + // }, + + // { + // label: isDropout + // ? t('COMMON.UNMARK_DROP_OUT') + // : t('COMMON.MARK_DROP_OUT'), + // icon: ( + // + // ), + // name: isDropout ? 'unmark-drop-out' : 'mark-drop-out', + // }, + { + label: t('COMMON.REMOVE_USER_FROM_CLASS'), + icon: ( + + ), + name: 'delete-User', + }, + ].filter( + (option) => + type == Role.STUDENT || + (option.name !== 'mark-drop-out' && + option.name !== 'unmark-drop-out') + ) } renderCustomContent={renderCustomContent} /> diff --git a/src/pages/centers/[cohortId].tsx b/src/pages/centers/[cohortId].tsx index 51eea413..4858ddbe 100644 --- a/src/pages/centers/[cohortId].tsx +++ b/src/pages/centers/[cohortId].tsx @@ -170,12 +170,12 @@ const TeachingCenterDetails = () => { setRemoveCohortId(cohortData?.cohortId); if (cohortData?.customField?.length) { - const district = cohortData.customField.find( + const district = cohortData?.customField.find( (item: CustomField) => item.label === 'DISTRICTS' ); const districtCode = district?.code || ''; const districtId = district?.fieldId || ''; - const state = cohortData.customField.find( + const state = cohortData?.customField.find( (item: CustomField) => item.label === 'STATES' ); const stateCode = state?.code || ''; @@ -186,9 +186,11 @@ const TeachingCenterDetails = () => { ); cohortData.address = - `${toPascalCase(district?.value)}, ${toPascalCase(state?.value)}` || - ''; + district?.value && state?.value + ? `${toPascalCase(district?.value)}, ${toPascalCase(state?.value)}` + : ''; } + setCohortDetails(cohortData); setCohortName(cohortData?.name); } diff --git a/src/pages/centers/[cohortId]/index.tsx b/src/pages/centers/[cohortId]/index.tsx index 78a84676..2d4fc3d6 100644 --- a/src/pages/centers/[cohortId]/index.tsx +++ b/src/pages/centers/[cohortId]/index.tsx @@ -54,10 +54,14 @@ import { showToastMessage } from '@/components/Toastify'; import { getEventList } from '@/services/EventService'; import manageUserStore from '@/store/manageUserStore'; -import { modifyAttendanceLimit, eventDaysLimit } from '../../../../app.config'; +import { + modifyAttendanceLimit, + eventDaysLimit, + ShowCenterSessionsTab, +} from '../../../../app.config'; const TeachingCenterDetails = () => { - const [value, setValue] = React.useState(1); + const [value, setValue] = React.useState(2); const [showDetails, setShowDetails] = React.useState(false); const [classId, setClassId] = React.useState(''); const router = useRouter(); @@ -120,7 +124,7 @@ const TeachingCenterDetails = () => { setOpenSchedule(true); }; - const handleSchedule = () => { }; + const handleSchedule = () => {}; const handleOpen = () => setOpen(true); const handleClose = () => { @@ -413,13 +417,15 @@ const TeachingCenterDetails = () => { }, }} > - + {ShowCenterSessionsTab && ( + + )} - {value === 1 && ( + {value === 1 && ShowCenterSessionsTab && ( <>