From 62925ca06485ce8d21bbb1c85deb1d0fbc8a9bab Mon Sep 17 00:00:00 2001 From: Rushikesh-Sonawane99 Date: Thu, 6 Jun 2024 13:55:32 +0530 Subject: [PATCH 1/2] Issue #PS-384 chore: Modified colors to display attendance percentage on attendance overview page and progressbar --- src/components/CohortAttendanceListView.tsx | 5 +++-- src/components/LearnerAttendanceStatsListView.tsx | 8 +++----- src/hooks/useDeterminePathColor.js | 5 +++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/components/CohortAttendanceListView.tsx b/src/components/CohortAttendanceListView.tsx index 59b9834d..d14a5579 100644 --- a/src/components/CohortAttendanceListView.tsx +++ b/src/components/CohortAttendanceListView.tsx @@ -4,7 +4,7 @@ import { CohortAttendanceListViewProps } from '@/utils/Interfaces'; import React from 'react'; import { useTheme } from '@mui/material/styles'; import { useTranslation } from 'next-i18next'; -import { lowLearnerAttendanceLimit } from '../../app.config'; +import useDeterminePathColor from '@/hooks/useDeterminePathColor'; const CohortAttendanceListView: React.FC = ({ cohortName, @@ -12,7 +12,8 @@ const CohortAttendanceListView: React.FC = ({ }) => { const { t } = useTranslation(); const theme = useTheme(); - const textColor = attendancePercent > lowLearnerAttendanceLimit ? theme.palette.success.main : theme.palette.error.main; + const determinePathColor = useDeterminePathColor(); + const textColor = determinePathColor(attendancePercent); return ( diff --git a/src/components/LearnerAttendanceStatsListView.tsx b/src/components/LearnerAttendanceStatsListView.tsx index 7b1b34b1..0e570503 100644 --- a/src/components/LearnerAttendanceStatsListView.tsx +++ b/src/components/LearnerAttendanceStatsListView.tsx @@ -6,9 +6,9 @@ import LearnerModal from './LearnerModal'; import Link from 'next/link'; import Loader from './Loader'; import { getUserDetails } from '@/services/ProfileService'; -import { lowLearnerAttendanceLimit } from '../../app.config'; import { useTheme } from '@mui/material/styles'; import { useTranslation } from 'react-i18next'; +import useDeterminePathColor from '@/hooks/useDeterminePathColor'; interface StudentsStatsListProps { name: string; @@ -27,10 +27,8 @@ const StudentsStatsList: React.FC = ({ }) => { const theme = useTheme(); const { t } = useTranslation(); - const textColor = - presentPercent > lowLearnerAttendanceLimit - ? theme.palette.success.main - : theme.palette.error.main; + const determinePathColor = useDeterminePathColor(); + const textColor = determinePathColor(presentPercent); // const handleStudentDetails = () => { // router.push(`/student-details/${cohortId}/${userId}`); diff --git a/src/hooks/useDeterminePathColor.js b/src/hooks/useDeterminePathColor.js index 108105aa..c372a232 100644 --- a/src/hooks/useDeterminePathColor.js +++ b/src/hooks/useDeterminePathColor.js @@ -1,12 +1,13 @@ import { useTheme } from '@mui/material/styles'; +import { avgLearnerAttendanceLimit, lowLearnerAttendanceLimit } from '../../app.config'; const useDeterminePathColor = () => { const theme = useTheme(); const determinePathColor = (presentPercentage) => { if (presentPercentage == 0) return theme.palette.warning['400']; - if (presentPercentage < 25) return theme.palette.error.main; - if (presentPercentage < 50) return theme.palette.action.activeChannel; + if (presentPercentage < lowLearnerAttendanceLimit) return theme.palette.error.main; + if (presentPercentage <= avgLearnerAttendanceLimit) return theme.palette.action.activeChannel; return theme.palette.success.main; }; From 2815b8225180228b4889f9b18b35be0938f616dd Mon Sep 17 00:00:00 2001 From: Rushikesh-Sonawane99 Date: Thu, 6 Jun 2024 16:04:52 +0530 Subject: [PATCH 2/2] Issue #PS-281 chore: Added dependency to update cohort attendance on bulk attendance update --- src/pages/dashboard.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/dashboard.tsx b/src/pages/dashboard.tsx index 10fbaa6e..f9f4d69f 100644 --- a/src/pages/dashboard.tsx +++ b/src/pages/dashboard.tsx @@ -390,7 +390,7 @@ const Dashboard: React.FC = () => { if (classId?.length) { getCohortMemberList(); } - }, [classId, selectedDate]); + }, [classId, selectedDate, handleSaveHasRun]); const showDetailsHandle = (dayStr: string) => { setSelectedDate(formatSelectedDate(dayStr));