diff --git a/public/locales/en/common.json b/public/locales/en/common.json index c35bb380..5279e23c 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -162,7 +162,12 @@ "UPDATE_AVAILABLE": "New Update Available!", "RELOAD_TO_UPDATE": "Get the latest features and improvements—update now to enjoy a smoother experience and stay up-to-date!", "NO_ASSIGNED_BOARDS":"No assigned Board for selected Center", - "YOU_HAVE_UNSAVED_CHANGES": "You have unsaved changes. Are you sure you want to go back?" + "YOU_HAVE_UNSAVED_CHANGES": "You have unsaved changes. Are you sure you want to go back?", + "ATTENDANCE_IS_USUALLY":" Attendance is usually auto-marked after the first session of the day.", + "ARE_YOU_SURE_MANUALLY" : "Are you sure you want to mark attendance manually?", + "USE_MANUAL":"Use manual marking only for technical issues, sessions on other platforms, or if not conducted online.", + "NOTE_MANUALLY":"Note: Manually marked attendance will override auto-attendance if it is later recorded.", + "YES_MANUALLY":"Yes, Mark Manually" }, "LOGIN_PAGE": { diff --git a/src/components/CohortFacilitatorList.tsx b/src/components/CohortFacilitatorList.tsx index 739dddd0..68c2bffd 100644 --- a/src/components/CohortFacilitatorList.tsx +++ b/src/components/CohortFacilitatorList.tsx @@ -39,6 +39,7 @@ const CohortLearnerList: React.FC = ({ const [loading, setLoading] = React.useState(false); const [userData, setUserData] = React.useState(); const [resData, setResData] = React.useState(); + console.log(userData); const [filteredData, setFilteredData] = React.useState(userData); const [searchTerm, setSearchTerm] = React.useState(''); @@ -67,9 +68,12 @@ const CohortLearnerList: React.FC = ({ } try { if (cohortId) { - const filters = { cohortId: cohortId }; - const limit = pagesLimit - const page=offset + const filters = { + cohortId: cohortId, + }; + const limit = pagesLimit; + const page = offset; + const response = await getMyCohortFacilitatorList({ limit, page, @@ -93,17 +97,17 @@ const CohortLearnerList: React.FC = ({ age: ageField ? ageField.value : null, }; }); - // setResData(userDetails) if (isMobile) { setInfiniteData([...infiniteData, ...userDetails]); setFilteredData(userDetails); + setUserData([...infiniteData, ...userDetails]); } else { setUserData(userDetails); setFilteredData(userDetails); setInfiniteData(userDetails); - setOffset(0) + setOffset(0); } setTotalCount(response.result?.totalCount); @@ -125,6 +129,7 @@ const CohortLearnerList: React.FC = ({ getCohortMemberList(); }, [cohortId, reloadState, page, infinitePage]); + const onDelete = () => {}; @@ -154,11 +159,26 @@ const CohortLearnerList: React.FC = ({ showToastMessage(t('COMMON.SOMETHING_WENT_WRONG'), 'error'); } } - const handleSearch = (searchTerm: string) => { - const filtered = userData?.filter((data) => - data?.name?.toLowerCase()?.includes(searchTerm) || data?.enrollmentNumber?.toLowerCase()?.includes(searchTerm) + const handleSearch = async (searchTerm: string) => { + const filtered = userData?.filter((data) =>{ + return data?.name?.toLowerCase()?.includes(searchTerm.toLowerCase()) || data?.enrollmentNumber?.toLowerCase()?.includes(searchTerm) + } ); - setFilteredData(filtered); + // const filters = { + // cohortId: cohortId, + // firstName: searchTerm + // }; + // const limit = pagesLimit; + // const page = offset; + // const response = await getMyCohortFacilitatorList({ + // limit, + // page, + // filters, + // }); + + setUserData(resData || []); + setFilteredData(resData || []); + }; const handlePageChange = (newPage: number) => { diff --git a/src/components/MarkBulkAttendance.tsx b/src/components/MarkBulkAttendance.tsx index 1e0fbce4..1e6af3d5 100644 --- a/src/components/MarkBulkAttendance.tsx +++ b/src/components/MarkBulkAttendance.tsx @@ -263,7 +263,7 @@ const MarkBulkAttendance: React.FC = ({ sx={{ padding: '0 10px' }} > - = ({ sx={{ '& .MuiPaper-root': { borderRight: `1px solid ${theme.palette.warning['A100']}`, + '@media (max-width: 900px)': { zIndex: '998 !important', + }, left: isRTL ? '0px !important' : '0px !important', width: isRTL ? '350px !important' : 'unset !important', diff --git a/src/components/Modal.tsx b/src/components/Modal.tsx index ac241a44..9974c986 100644 --- a/src/components/Modal.tsx +++ b/src/components/Modal.tsx @@ -1,10 +1,17 @@ -import { Box, Modal, Typography } from '@mui/material'; +import { Box, Divider, Modal, Typography } from '@mui/material'; +import { modalStyles } from '@/styles/modalStyles'; import CloseSharpIcon from '@mui/icons-material/CloseSharp'; +import { useTheme } from '@mui/material/styles'; import PropTypes from 'prop-types'; import { useTranslation } from 'react-i18next'; import ButtonFunctional from './ButtonComponent'; -import { modalStyles } from '@/styles/modalStyles'; + +import { + getDayMonthYearFormat, + shortDateFormat +} from '../utils/Helper'; + interface ModalProps { open: boolean; @@ -14,10 +21,12 @@ interface ModalProps { children?: React.ReactNode; btnText: string; handlePrimaryAction: () => void; - secondaryBtnText?: string; + secondaryBtnText?: string; handleSecondaryAction?: () => void; + selectedDate?: Date; // Ensure selectedDate is always a Date if provided } + const ModalComponent: React.FC = ({ open, onClose, @@ -26,10 +35,14 @@ const ModalComponent: React.FC = ({ children, btnText, handlePrimaryAction, + selectedDate, secondaryBtnText='Back', handleSecondaryAction=(()=>{console.log('Button2')}), }) => { const { t } = useTranslation(); + const theme = useTheme(); + + return ( @@ -42,9 +55,25 @@ const ModalComponent: React.FC = ({ justifyContent="space-between" alignItems="center" > - - {heading} - + + + {heading} + + + {selectedDate + ? getDayMonthYearFormat(shortDateFormat(selectedDate)) + : 'N/A'} + + + = ({ aria-label="Close" /> + {SubHeading} {children} + + {secondaryBtnText && handleSecondaryAction && ( | null = null; if (!isEliminatedFromBuild('SessionCardFooter', 'component')) { @@ -164,7 +165,7 @@ const Dashboard: React.FC = () => { dropoutCount: 0, bulkAttendanceStatus: '', }); - + const [isRemoteCohort, setIsRemoteCohort] = React.useState(false); const handleAttendanceDataUpdate = (data: any) => { setAttendanceData(data); }; @@ -254,6 +255,7 @@ const Dashboard: React.FC = () => { (item: any) => item?.label === 'BLOCKS' ); const cohortData = response?.result?.userData?.customFields; + const state = cohortData?.find( (item: CustomField) => item.label === 'STATES' @@ -526,10 +528,7 @@ const Dashboard: React.FC = () => { }; const handleModalToggle = () => { - setOpen(!open); - ReactGA.event('mark/modify-attendance-button-clicked-dashboard', { - teacherId: userId, - }); + setOpen(!open); const telemetryInteract = { context: { @@ -546,6 +545,27 @@ const Dashboard: React.FC = () => { telemetryFactory.interact(telemetryInteract); }; + const handleRemoteSession = () => { + try { + const teacherApp = JSON.parse(localStorage.getItem("teacherApp") ?? "null"); + const cohort = teacherApp?.state?.cohorts?.find?.( + (c: any) => c.cohortId === classId + ); + const REMOTE_COHORT_TYPE = "REMOTE" as const; + if (cohort?.cohortType === REMOTE_COHORT_TYPE) { + setIsRemoteCohort(true); + ReactGA.event('mark/modify-attendance-button-clicked-dashboard', { + teacherId: userId, + }); + } else { + handleModalToggle() + } + } catch (error) { + console.error('Error parsing teacher app data:', error); + handleModalToggle(); + } + } + const getMonthName = (dateString: string) => { try { const parsedDate = parse(dateString, 'yyyy-MM-dd', new Date()); @@ -627,7 +647,7 @@ const Dashboard: React.FC = () => { }; telemetryFactory.interact(telemetryInteract); }; - + const viewTimeTable = () => { if (classId !== 'all') { router.push( @@ -639,6 +659,8 @@ const Dashboard: React.FC = () => { const handleClose = () => { setOpen(false); + setIsRemoteCohort(false) + // setTest(false) }; const todayDate = getTodayDate(); @@ -809,8 +831,7 @@ const Dashboard: React.FC = () => { const darkMode = typeof window !== 'undefined' && window.localStorage ? localStorage.getItem('mui-mode') - : null; - + : null; return ( <> { @@ -882,7 +903,7 @@ const Dashboard: React.FC = () => { > {t('DASHBOARD.DAY_WISE_ATTENDANCE')} - + = () => { width: '15%', }, }} - onClick={handleModalToggle} + onClick={handleRemoteSession} disabled={ currentAttendance === 'futureDate' || classId === 'all' || @@ -1096,7 +1117,7 @@ const Dashboard: React.FC = () => { {open && ( - = () => { bulkStatus={attendanceData?.bulkAttendanceStatus} /> )} + { + isRemoteCohort && ( + handleModalToggle()} + > + + + {t("COMMON.ARE_YOU_SURE_MANUALLY")} + + + {t('COMMON.ATTENDANCE_IS_USUALLY')} + + + {t("COMMON.USE_MANUAL")} + + + {t("COMMON.NOTE_MANUALLY")} + + + + ) + }