diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 05552f6a..6860a9a7 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -166,7 +166,8 @@ "LEARNER": "Learners", "ATTENDANCE_COMPARISON": "Attendance Comparison", "CENTER_TYPE": "Center Type", - "BLOCK_AVERAGE_ATTENDANCE": "Block Average Attendance", + "REMOTE_AVERAGE_ATTENDANCE": "Remote Average Attendance", + "REGULAR_AVERAGE_ATTENDANCE": "Regular Average Attendance", "BLOCK": "Block", "ATTENDANCE": "Attendance (%)" }, diff --git a/src/components/AttendanceComparison.tsx b/src/components/AttendanceComparison.tsx index 59abf4b6..ec21bfa8 100644 --- a/src/components/AttendanceComparison.tsx +++ b/src/components/AttendanceComparison.tsx @@ -22,7 +22,7 @@ import { useTranslation } from 'next-i18next'; import useStore from '../store/store'; import { useTheme } from '@mui/material/styles'; import { overallAttendanceInPercentageStatusList } from '@/services/AttendanceService'; -import { cohortPrivileges } from '@/utils/app.constant'; +import { CenterType, cohortPrivileges } from '@/utils/app.constant'; interface AttendanceComparisonProps { blockName: string; @@ -158,59 +158,61 @@ const AttendanceComparison: React.FC = ({ {t('DASHBOARD.CENTER_TYPE')} - - } - label="Regular" - sx={{ - '& .MuiFormControlLabel-label': { - color: 'black', - fontSize: '18px', - }, - }} - /> - - } - label="Remote" - sx={{ - '& .MuiFormControlLabel-label': { - color: 'black', - fontSize: '18px', - }, - }} - /> - - + row + aria-label="center type" + name="centerType" + value={centerType} + onChange={handleCenterTypeChange} + > + + } + label="Regular" + sx={{ + '& .MuiFormControlLabel-label': { + color: 'black', + fontSize: '18px', + }, + }} + /> + + } + label="Remote" + sx={{ + '& .MuiFormControlLabel-label': { + color: 'black', + fontSize: '18px', + }, + }} + /> + - - {t('DASHBOARD.BLOCK_AVERAGE_ATTENDANCE')}:{' '} - {averageAttendance.toFixed(2)}% + + {centerType === CenterType.REMOTE + ? t('DASHBOARD.REMOTE_AVERAGE_ATTENDANCE') + : t('DASHBOARD.REGULAR_AVERAGE_ATTENDANCE')} + : {averageAttendance.toFixed(2)}% - + + = ({ - + ); }; diff --git a/src/components/CohortSelectionSection.tsx b/src/components/CohortSelectionSection.tsx index ab1c996c..a161b4cc 100644 --- a/src/components/CohortSelectionSection.tsx +++ b/src/components/CohortSelectionSection.tsx @@ -13,7 +13,7 @@ import { getCohortList } from '@/services/CohortServices'; import useStore from '@/store/store'; import { ICohort } from '@/utils/Interfaces'; import { CustomField } from '@/utils/Interfaces'; -import { cohortHierarchy } from '@/utils/app.constant'; +import { CenterType, cohortHierarchy } from '@/utils/app.constant'; import { useTheme } from '@mui/material/styles'; import { useTranslation } from 'next-i18next'; import ReactGA from 'react-ga4'; @@ -355,17 +355,17 @@ const CohortSelectionSection: React.FC = ({ {cohortsData?.length !== 0 ? ( manipulatedCohortData?.map((cohort) => ( - {cohort.name} ({cohort?.typeOfCohort}) - + key={cohort.cohortId} + value={cohort.cohortId} + style={{ + fontWeight: '500', + fontSize: '14px', + color: theme.palette.warning['A200'], + textTransform: 'capitalize', + }} + > + {cohort.name} {cohort?.typeOfCohort === CenterType.REGULAR || CenterType.UNKNOWN &&`(${cohort.typeOfCohort})`} + )) ) : ( = ({ (event: React.KeyboardEvent | React.MouseEvent) => { setCohortDeleteId(isFromFLProfile ? teacherUserId : user.userId); if (!isFromFLProfile) { - console.log(user); const cohortNamesArray = user?.cohortNames?.split(', '); - const centerNames = cohortNamesArray?.map((cohortName: string) => cohortName.trim()) || [t('ATTENDANCE.N/A')]; + const centerNames = cohortNamesArray?.map((cohortName: string) => + cohortName.trim() + ) || [t('ATTENDANCE.N/A')]; setCenters(centerNames); setSelectedUser(user); } @@ -635,7 +637,11 @@ const ManageUser: React.FC = ({ }} > {user?.cohortNames - ? `${user.cohortNames}` + ? `${user.cohortNames + .charAt(0) + .toUpperCase() + + user.cohortNames.slice(1) + }` : t('ATTENDANCE.N/A')} @@ -643,7 +649,13 @@ const ManageUser: React.FC = ({ { - isMobile ? toggleDrawer('bottom', true, user)(event) : handleMenuOpen(event) + isMobile + ? toggleDrawer( + 'bottom', + true, + user + )(event) + : handleMenuOpen(event); }} sx={{ fontSize: '24px', @@ -665,7 +677,13 @@ const ManageUser: React.FC = ({ width: '100%', }} > - + {t('COMMON.NO_DATA_FOUND')} @@ -695,7 +713,7 @@ const ManageUser: React.FC = ({ { label: t('COMMON.REASSIGN_BLOCKS'), icon: ( - ), @@ -721,6 +739,20 @@ const ManageUser: React.FC = ({ }, ]} > + + {selectedUser?.name + ? selectedUser.name.charAt(0).toUpperCase() + + selectedUser.name.slice(1) + : ''} + = ({ padding={'1rem'} borderRadius={'1rem'} > - + {t('COMMON.CENTERS_ASSIGNED', { block: newStore.block, })} diff --git a/src/components/center/RenameCenterModal.tsx b/src/components/center/RenameCenterModal.tsx index af2c6e4e..1bab7ca9 100644 --- a/src/components/center/RenameCenterModal.tsx +++ b/src/components/center/RenameCenterModal.tsx @@ -19,11 +19,15 @@ import { showToastMessage } from '../Toastify'; interface CreateBlockModalProps { open: boolean; handleClose: () => void; + reloadState: boolean; + setReloadState: React.Dispatch>; } const RenameCenterModal: React.FC = ({ open, handleClose, + reloadState, + setReloadState, }) => { const router = useRouter(); const { t } = useTranslation(); @@ -34,6 +38,12 @@ const RenameCenterModal: React.FC = ({ const [centerName, setCenterName] = useState(''); const [error, setError] = useState(''); + React.useEffect(() => { + if (reloadState) { + setReloadState(false); + } + }, [reloadState, setReloadState]); + const handleTextFieldChange = ( event: React.ChangeEvent ) => { @@ -57,8 +67,9 @@ const RenameCenterModal: React.FC = ({ const name = centerName; const response = await renameFacilitator(cohortId, name); - + setReloadState(true); showToastMessage(t('CENTERS.CENTER_RENAMED'), 'success'); + handleClose(); }; diff --git a/src/pages/centers/[cohortId].tsx b/src/pages/centers/[cohortId].tsx index 31755560..ef07c5a0 100644 --- a/src/pages/centers/[cohortId].tsx +++ b/src/pages/centers/[cohortId].tsx @@ -193,7 +193,7 @@ const TeachingCenterDetails = () => { } }; getCohortData(); - }, []); + }, [reloadState]); useEffect(() => { const getSessionsData = async () => { @@ -383,7 +383,7 @@ const TeachingCenterDetails = () => { {t('CENTERS.RENAME_CENTER')} { + onClick={() => { setOpenDeleteCenterModal(true); handleMenuClose(); }} @@ -397,6 +397,8 @@ const TeachingCenterDetails = () => { { { {/* Regular Centers */} {filteredCenters.some( (center) => - center.centerType?.toUpperCase() === 'REGULAR' || + center.centerType?.toUpperCase() === CenterType.REGULAR || center.centerType === '' ) && ( <> @@ -437,7 +437,7 @@ const TeachingCenters = () => { .filter( (center) => center?.centerType?.toUpperCase() === - 'REGULAR' || center?.centerType === '' + CenterType.REGULAR || center?.centerType === '' ) .map((center) => ( { {/* Remote Centers */} {filteredCenters.some( - (center) => center.centerType?.toUpperCase() === 'REMOTE' + (center) => center.centerType?.toUpperCase() === CenterType.REMOTE ) && ( <> { {filteredCenters .filter( (center) => - center.centerType?.toUpperCase() === 'REMOTE' + center.centerType?.toUpperCase() === CenterType.REMOTE ) .map((center) => (