Skip to content

Commit

Permalink
Task #224976: removed dropout and reassign center from learner list ,…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
upendraTekdi committed Aug 20, 2024
1 parent 7bceb4c commit f81faab
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 133 deletions.
3 changes: 3 additions & 0 deletions app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,6 @@ export const ShowManageUsers = false;

//mark attendance model
export const ShowSelfAttendance = true;

export const reassignCenters = false;
export const markdDropOut = false;
6 changes: 4 additions & 2 deletions public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -374,7 +375,6 @@
"MANAGE_USERS": {
"CENTERS_REQUESTED_SUCCESSFULLY": "Center Requested Successfully",
"CENTERS_REQUEST_FAILED": "Center Requested Failed"

},
"FORM": {
"FULL_NAME": "Full Name",
Expand Down Expand Up @@ -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.",
Expand Down
7 changes: 4 additions & 3 deletions src/components/CohortSelectionSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,15 @@ const CohortSelectionSection: React.FC<CohortSelectionSectionProps> = ({
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);
Expand Down Expand Up @@ -261,6 +261,7 @@ const CohortSelectionSection: React.FC<CohortSelectionSectionProps> = ({
setLoading(false);
} catch (error) {
console.error('Error fetching cohort list', error);
console.log('error', error);
setLoading(false);
showToastMessage(t('COMMON.SOMETHING_WENT_WRONG'), 'error');
}
Expand Down
210 changes: 106 additions & 104 deletions src/components/LearnersListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const LearnersListItem: React.FC<LearnerListProps> = ({
center,
showMiniProfile,
onLearnerDelete,
isFromProfile = false
isFromProfile = false,
}) => {
const [state, setState] = React.useState({
bottom: false,
Expand Down Expand Up @@ -119,20 +119,20 @@ const LearnersListItem: React.FC<LearnerListProps> = ({

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 }));
Expand Down Expand Up @@ -190,7 +190,7 @@ const LearnersListItem: React.FC<LearnerListProps> = ({
});
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', {
Expand Down Expand Up @@ -242,7 +242,7 @@ const LearnersListItem: React.FC<LearnerListProps> = ({
});
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', {
Expand Down Expand Up @@ -320,7 +320,7 @@ const LearnersListItem: React.FC<LearnerListProps> = ({

const filteredFields = filterMiniProfileFields(learnerState.customFieldsData);

const getTeamLeadersCenters = async () => { };
const getTeamLeadersCenters = async () => {};

const handleCloseCentersModal = () => {
setOpenCentersModal(false);
Expand Down Expand Up @@ -389,8 +389,6 @@ const LearnersListItem: React.FC<LearnerListProps> = ({
return null;
};



const handleUserDelete = () => {
setIsUserDeleted(true);
onLearnerDelete();
Expand Down Expand Up @@ -427,8 +425,8 @@ const LearnersListItem: React.FC<LearnerListProps> = ({
borderBottom: `1px solid ${theme.palette.warning['A100']}`,
},
'@media (min-width: 900px)': {
marginTop: '20px'
}
marginTop: '20px',
},
}}
>
<Box
Expand All @@ -442,7 +440,7 @@ const LearnersListItem: React.FC<LearnerListProps> = ({
border: `1px solid ${theme.palette.warning['A100']}`,
padding: '10px',
borderRadius: '8px',
background: theme.palette.warning['A400']
background: theme.palette.warning['A400'],
},
}}
>
Expand Down Expand Up @@ -575,11 +573,11 @@ const LearnersListItem: React.FC<LearnerListProps> = ({
</Box>
</Box>



<MoreVertIcon
onClick={(event) => {
isMobile ? toggleDrawer('bottom', true)(event) : handleMenuOpen(event)
isMobile
? toggleDrawer('bottom', true)(event)
: handleMenuOpen(event);
}}
sx={{
fontSize: isMobile ? '24px' : 'inherit',
Expand All @@ -602,86 +600,90 @@ const LearnersListItem: React.FC<LearnerListProps> = ({
optionList={
block
? [
{
label: t('COMMON.REASSIGN_BLOCKS_REQUEST'),
icon: (
<LocationOnOutlinedIcon
sx={{ color: theme.palette.warning['300'] }}
/>
),
name: 'reassign-block-request',
},
{
label: t('COMMON.REASSIGN_CENTERS'),
icon: (
<ApartmentIcon
sx={{ color: theme.palette.warning['300'] }}
/>
),
name: 'reassign-centers',
},
{
label: isDropout
? t('COMMON.UNMARK_DROP_OUT')
: t('COMMON.MARK_DROP_OUT'),
icon: (
<NoAccountsIcon
sx={{ color: theme.palette.warning['300'] }}
/>
),
name: isDropout ? 'unmark-drop-out' : 'mark-drop-out',
},
{
label: t('COMMON.DELETE_USER'),
icon: (
<DeleteOutlineIcon
sx={{ color: theme.palette.warning['300'] }}
/>
),
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: (
// <LocationOnOutlinedIcon
// sx={{ color: theme.palette.warning['300'] }}
// />
// ),
// name: 'reassign-block-request',
// },

// {
// label: t('COMMON.REASSIGN_CENTERS'),
// icon: (
// <ApartmentIcon
// sx={{ color: theme.palette.warning['300'] }}
// />
// ),
// name: 'reassign-centers',
// },

// {
// label: isDropout
// ? t('COMMON.UNMARK_DROP_OUT')
// : t('COMMON.MARK_DROP_OUT'),
// icon: (
// <NoAccountsIcon
// sx={{ color: theme.palette.warning['300'] }}
// />
// ),
// name: isDropout ? 'unmark-drop-out' : 'mark-drop-out',
// },

{
label: t('COMMON.REMOVE_USER_FROM_CLASS'),
icon: (
<DeleteOutlineIcon
sx={{ color: theme.palette.warning['300'] }}
/>
),
name: 'delete-User',
},
].filter(
(option) =>
type == Role.STUDENT ||
(option.name !== 'mark-drop-out' &&
option.name !== 'unmark-drop-out')
)
: [
{
label: t('COMMON.REASSIGN_CENTERS'),
icon: (
<ApartmentIcon
sx={{ color: theme.palette.warning['300'] }}
/>
),
name: 'reassign-centers',
},
{
label: isDropout
? t('COMMON.UNMARK_DROP_OUT')
: t('COMMON.MARK_DROP_OUT'),
icon: (
<NoAccountsIcon
sx={{ color: theme.palette.warning['300'] }}
/>
),
name: isDropout ? 'unmark-drop-out' : 'mark-drop-out',
},
{
label: t('COMMON.DELETE_USER'),
icon: (
<DeleteOutlineIcon
sx={{ color: theme.palette.warning['300'] }}
/>
),
name: 'delete-User',
},
].filter(
(option) =>
type == Role.STUDENT ||
(option.name !== 'mark-drop-out' &&
option.name !== 'unmark-drop-out')
)
// {
// label: t('COMMON.REASSIGN_CENTERS'),
// icon: (
// <ApartmentIcon
// sx={{ color: theme.palette.warning['300'] }}
// />
// ),
// name: 'reassign-centers',
// },

// {
// label: isDropout
// ? t('COMMON.UNMARK_DROP_OUT')
// : t('COMMON.MARK_DROP_OUT'),
// icon: (
// <NoAccountsIcon
// sx={{ color: theme.palette.warning['300'] }}
// />
// ),
// name: isDropout ? 'unmark-drop-out' : 'mark-drop-out',
// },
{
label: t('COMMON.REMOVE_USER_FROM_CLASS'),
icon: (
<DeleteOutlineIcon
sx={{ color: theme.palette.warning['300'] }}
/>
),
name: 'delete-User',
},
].filter(
(option) =>
type == Role.STUDENT ||
(option.name !== 'mark-drop-out' &&
option.name !== 'unmark-drop-out')
)
}
renderCustomContent={renderCustomContent}
/>
Expand Down
10 changes: 6 additions & 4 deletions src/pages/centers/[cohortId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 || '';
Expand All @@ -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);
}
Expand Down
Loading

0 comments on commit f81faab

Please sign in to comment.