From 23bc3aba7a29d114043d0380c531df155a82ad9e Mon Sep 17 00:00:00 2001 From: suvarnakale Date: Tue, 2 Jul 2024 11:15:13 +0530 Subject: [PATCH] Issue #0000 chore: linted and formatted the code --- public/locales/hi/common.json | 4 +- public/locales/mr/common.json | 13 +- public/locales/or/common.json | 10 +- src/components/AttendanceStatusListView.tsx | 175 +++++++++--------- src/components/CohortLearnerList.tsx | 19 +- src/components/DateRangePopup.tsx | 5 +- src/components/DropoutLabel.tsx | 53 +++--- .../LearnerAttendanceStatsListView.tsx | 66 +++---- src/components/ManageCentersModal.tsx | 2 +- src/components/MonthCalender.tsx | 14 +- src/components/blocks/CreateBlockModal.tsx | 2 - src/pages/_app.tsx | 5 +- src/pages/attendance-history.tsx | 24 ++- src/pages/blocks/centre.tsx | 17 +- src/pages/blocks/index.tsx | 5 +- src/pages/centers/[cohortId].tsx | 4 +- src/pages/centers/index.tsx | 2 +- src/pages/dashboard.tsx | 5 +- src/pages/login.tsx | 2 +- src/pages/profile.tsx | 48 +++-- src/services/MyClassDetailsService.ts | 7 +- src/services/queries.ts | 32 ++-- src/styles/customTheme.tsx | 3 +- src/utils/Helper.ts | 68 +++++-- src/utils/attendanceStats.ts | 4 - 25 files changed, 318 insertions(+), 271 deletions(-) diff --git a/public/locales/hi/common.json b/public/locales/hi/common.json index 1983beec..435eee29 100644 --- a/public/locales/hi/common.json +++ b/public/locales/hi/common.json @@ -9,7 +9,7 @@ "UPDATE_ATTENDANCE": "उपस्थिति अपडेट करें", "LOADING": "लोडिंग", "SAVE": "सहेजें", - "SEARCH" : "खोजें..", + "SEARCH": "खोजें..", "UPDATE": "अद्यतन करें", "CLEAR_ALL": "सब हटाएं", "SEARCH_STUDENT": "छात्र खोजें", @@ -249,7 +249,7 @@ "CREATE": "बनाएँ", "SEARCH_BLOCKS": "ब्लॉक खोजें" }, - "CENTERS": { + "CENTERS": { "REGULAR_CENTERS": "नियमित केंद्र", "REMOTE_CENTERS": "दूरस्थ केंद्र", "CENTER_TYPE": "केंद्र प्रकार", diff --git a/public/locales/mr/common.json b/public/locales/mr/common.json index b2daf248..50541d81 100644 --- a/public/locales/mr/common.json +++ b/public/locales/mr/common.json @@ -9,7 +9,7 @@ "UPDATE_ATTENDANCE": "उपस्थिती अद्यतनित करा", "LOADING": "लोड होत आहे", "SAVE": "जतन करा", - "SEARCH" : "शोधा..", + "SEARCH": "शोधा..", "UPDATE": "अपडेट करा", "CLEAR_ALL": "सर्व काढा", "SEARCH_STUDENT": "विद्यार्थी शोधा", @@ -242,22 +242,19 @@ }, "BLOCKS": { "TEACHING_BLOCKS": "शिक्षण ब्लॉक्स", - - + "CREATE_NEW": "नवीन तयार करा", "NEW_BLOCK": "नवीन ब्लॉक", "BLOCK_NAME": "ब्लॉकचं नाव", "CREATE": "तयार करा", "SEARCH_BLOCKS": "ब्लॉक शोधा" - }, - "CENTERS": { + "CENTERS": { "REGULAR_CENTERS": "नियमित केंद्र", "REMOTE_CENTERS": "दूरस्थ केंद्र", "CENTER_TYPE": "केंद्र प्रकार", "REGULAR": "नियमित", "REMOTE": "दूरस्थ" - } - } - + } +} diff --git a/public/locales/or/common.json b/public/locales/or/common.json index da425d4f..bd803d84 100644 --- a/public/locales/or/common.json +++ b/public/locales/or/common.json @@ -8,7 +8,7 @@ "MARK_ATTENDANCE": "ଉପସ୍ଥିତି ଚିହ୍ନିତ କର", "UPDATE_ATTENDANCE": "ଉପସ୍ଥିତି ଅପଡେଟ କର", "SAVE": "ସେଭ କର", - "SEARCH" : "ସନ୍ଧାନ କରନ୍ତୁ..", + "SEARCH": "ସନ୍ଧାନ କରନ୍ତୁ..", "UPDATE": "ଅପଡେଟ", "MODIFY": "ସଂଶୋଧିତ କର", "CLEAR_ALL": "ସବୁ ସଫା କର", @@ -191,12 +191,12 @@ }, "BLOCKS": { "TEACHING_BLOCKS": "ଶିକ୍ଷା ବ୍ଲକ୍ସ", - + "CREATE_NEW": "ନୂତନ ସୃଷ୍ଟି କରନ୍ତୁ", "NEW_BLOCK": "ନୂଆ ବ୍ଲକ୍", "BLOCK_NAME": "ବ୍ଲକ୍ ନାମ", "CREATE": "ତିଆରି କରନ୍ତୁ", - + "SEARCH_BLOCKS": "ବ୍ଲକ୍‌ ଖୋଜନ୍ତୁ" }, "CENTERS": { @@ -205,5 +205,5 @@ "CENTER_TYPE": "କେନ୍ଦ୍ର ପ୍ରକାର", "REGULAR": "ସାଧାରଣ", "REMOTE": "ଦୂରସ୍ଥ" - } - } \ No newline at end of file + } +} diff --git a/src/components/AttendanceStatusListView.tsx b/src/components/AttendanceStatusListView.tsx index 8afd35ca..126586f6 100644 --- a/src/components/AttendanceStatusListView.tsx +++ b/src/components/AttendanceStatusListView.tsx @@ -157,93 +157,94 @@ const AttendanceStatusListView: React.FC = ({ userData?.name )} - {userData?.memberStatus === Status.DROPOUT ? - - : - <> - - handleClickAction( - isBulkAction, - ATTENDANCE_ENUM.PRESENT, - isBulkAction ? '' : userData?.userId - ) - } - > - {[userData?.attendance, bulkAttendanceStatus].includes( - ATTENDANCE_ENUM.PRESENT - ) ? ( - - ) : ( - - )} - theme.palette.warning[400] }} - > - {t('ATTENDANCE.PRESENT')} - - - - handleClickAction( - isBulkAction, - ATTENDANCE_ENUM.ABSENT, - isBulkAction ? '' : userData?.userId - ) - } - > - {[userData?.attendance, bulkAttendanceStatus].includes( - ATTENDANCE_ENUM.ABSENT - ) ? ( - - ) : ( - - )} - theme.palette.warning[400] }} - > - {t('ATTENDANCE.ABSENT')} - - - } + {userData?.memberStatus === Status.DROPOUT ? ( + + ) : ( + <> + + handleClickAction( + isBulkAction, + ATTENDANCE_ENUM.PRESENT, + isBulkAction ? '' : userData?.userId + ) + } + > + {[userData?.attendance, bulkAttendanceStatus].includes( + ATTENDANCE_ENUM.PRESENT + ) ? ( + + ) : ( + + )} + theme.palette.warning[400] }} + > + {t('ATTENDANCE.PRESENT')} + + + + handleClickAction( + isBulkAction, + ATTENDANCE_ENUM.ABSENT, + isBulkAction ? '' : userData?.userId + ) + } + > + {[userData?.attendance, bulkAttendanceStatus].includes( + ATTENDANCE_ENUM.ABSENT + ) ? ( + + ) : ( + + )} + theme.palette.warning[400] }} + > + {t('ATTENDANCE.ABSENT')} + + + + )} ); diff --git a/src/components/CohortLearnerList.tsx b/src/components/CohortLearnerList.tsx index 7e2fb3dc..aa486e63 100644 --- a/src/components/CohortLearnerList.tsx +++ b/src/components/CohortLearnerList.tsx @@ -19,13 +19,17 @@ interface UserDataProps { cohortMembershipId: string; enrollmentNumber: string; } -interface CohortLearnerListProp{ - cohortId: any, +interface CohortLearnerListProp { + cohortId: any; reloadState: boolean; setReloadState: React.Dispatch>; } -const CohortLearnerList : React.FC = ({cohortId, reloadState, setReloadState}) => { +const CohortLearnerList: React.FC = ({ + cohortId, + reloadState, + setReloadState, +}) => { const [loading, setLoading] = React.useState(false); const [userData, setUserData] = React.useState(); @@ -37,7 +41,7 @@ const CohortLearnerList : React.FC = ({cohortId, reloadSt try { if (cohortId) { const page = 0; - const filters = {cohortId: cohortId}; + const filters = { cohortId: cohortId }; const response = await getMyCohortMemberList({ limit, page, @@ -71,6 +75,7 @@ const CohortLearnerList : React.FC = ({cohortId, reloadSt getCohortMemberList(); }, [cohortId, reloadState]); + console.log('userData', userData); return (
{loading ? ( @@ -81,13 +86,13 @@ const CohortLearnerList : React.FC = ({cohortId, reloadSt return ( ); diff --git a/src/components/DateRangePopup.tsx b/src/components/DateRangePopup.tsx index c38413ad..d23efcde 100644 --- a/src/components/DateRangePopup.tsx +++ b/src/components/DateRangePopup.tsx @@ -148,14 +148,13 @@ const DateRangePopup: React.FC = ({ } catch (error) { console.error('Failed to parse stored dates:', error); } - } + } } }, []); const getDateRange = (index: number | null) => { const today = new Date(); const formatDate = (date: Date) => { - console.log('date', date); if (typeof date === 'object') { // return date?.toISOString()?.split('T')[0];} const localDate = new Date( @@ -216,7 +215,6 @@ const DateRangePopup: React.FC = ({ setDateRangeArray(date); setDisplayCalendarFromDate(getDayAndMonthName(date[0])); setDisplayCalendarToDate(getDayAndMonthName(date[1])); - // toggleCalendarModal(); } }; @@ -298,6 +296,7 @@ const DateRangePopup: React.FC = ({ color: index === 4 ? theme.palette.secondary.main : '#4D4639', '&:hover': { backgroundColor: 'transparent', + color: '#0D599E', }, }} > diff --git a/src/components/DropoutLabel.tsx b/src/components/DropoutLabel.tsx index b9bd09a8..e0ea7d7a 100644 --- a/src/components/DropoutLabel.tsx +++ b/src/components/DropoutLabel.tsx @@ -1,32 +1,35 @@ -import { Box, Typography } from '@mui/material' +import { Box, Typography } from '@mui/material'; import { useTheme } from '@mui/material/styles'; import { useTranslation } from 'next-i18next'; -import React from 'react' - +import React from 'react'; const DropoutLabel = () => { - const theme = useTheme(); - const { t } = useTranslation(); + const theme = useTheme(); + const { t } = useTranslation(); return ( - {t('COMMON.DROPPED_OUT')} - - ) -} + sx={{ + fontSize: '12px', + color: theme.palette.warning['300'], + background: theme.palette.error.light, + fontWeight: '500', + borderRadius: '8px', + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + gap: '4px', + padding: '4px 8px', + my: '0.5rem', + mr: '11px', + }} + > + + {t('COMMON.DROPPED_OUT')} + + + ); +}; -export default DropoutLabel \ No newline at end of file +export default DropoutLabel; diff --git a/src/components/LearnerAttendanceStatsListView.tsx b/src/components/LearnerAttendanceStatsListView.tsx index 2b125d5c..b643aea7 100644 --- a/src/components/LearnerAttendanceStatsListView.tsx +++ b/src/components/LearnerAttendanceStatsListView.tsx @@ -19,7 +19,7 @@ interface StudentsStatsListProps { classesMissed: number; userId?: string; cohortId?: string; - memberStatus? : string; + memberStatus?: string; } const StudentsStatsList: React.FC = ({ @@ -28,7 +28,7 @@ const StudentsStatsList: React.FC = ({ classesMissed, userId, cohortId, - memberStatus + memberStatus, }) => { const theme = useTheme(); const { t } = useTranslation(); @@ -143,37 +143,37 @@ const StudentsStatsList: React.FC = ({ - {memberStatus === Status.DROPOUT ? - - - - : - <> - - - {presentPercent}% - - - - - {classesMissed} - - - - } + {memberStatus === Status.DROPOUT ? ( + + + + ) : ( + <> + + + {presentPercent}% + + + + + {classesMissed} + + + + )} diff --git a/src/components/ManageCentersModal.tsx b/src/components/ManageCentersModal.tsx index bb2719b3..c781ad9a 100644 --- a/src/components/ManageCentersModal.tsx +++ b/src/components/ManageCentersModal.tsx @@ -66,7 +66,7 @@ const ManageCentersModal: React.FC = ({ const currentIndex = prevCheckedCenters.indexOf(name); const isCurrentlyChecked = currentIndex !== -1; - let newChecked = [...prevCheckedCenters]; + const newChecked = [...prevCheckedCenters]; if (isCurrentlyChecked) { newChecked.splice(currentIndex, 1); diff --git a/src/components/MonthCalender.tsx b/src/components/MonthCalender.tsx index 0578e85f..547ee001 100644 --- a/src/components/MonthCalender.tsx +++ b/src/components/MonthCalender.tsx @@ -18,7 +18,7 @@ interface CalendarWithAttendanceProps { onChange: (date: Date) => void; onDateChange: (date: Date | Date[] | null) => void; selectionType?: 'single' | 'range'; -selectedRangeRetention?:Date | null | undefined | [Date | null, Date | null]; + selectedRangeRetention?: Date | null | undefined | [Date | null, Date | null]; } type AttendanceData = { @@ -40,7 +40,7 @@ const MonthCalender: React.FC = ({ onChange, onDateChange, selectionType, - selectedRangeRetention + selectedRangeRetention, }) => { const [date, setDate] = useState< Date | null | undefined | [Date | null, Date | null] @@ -139,11 +139,15 @@ const MonthCalender: React.FC = ({ }, [selectedDates, onDateChange]); useEffect(() => { - if (typeof window !== 'undefined' && window.localStorage && selectionType === "range") { + if ( + typeof window !== 'undefined' && + window.localStorage && + selectionType === 'range' + ) { const retentionDate = localStorage.getItem('selectedRangeArray'); if (retentionDate) { try { - let retention = JSON.parse(retentionDate); + const retention = JSON.parse(retentionDate); if (retention) { handleDateChange(retention); } @@ -279,7 +283,7 @@ const MonthCalender: React.FC = ({ } else { console.error('newDate is undefined'); } - if (newDate !== undefined) { + if (newDate !== undefined) { let datesToSet: [Date | null, Date | null]; if (Array.isArray(newDate)) { datesToSet = [newDate[0] || null, newDate[1] || null]; diff --git a/src/components/blocks/CreateBlockModal.tsx b/src/components/blocks/CreateBlockModal.tsx index fce2f871..f534d729 100644 --- a/src/components/blocks/CreateBlockModal.tsx +++ b/src/components/blocks/CreateBlockModal.tsx @@ -110,6 +110,4 @@ const CreateBlockModal: React.FC = ({ ); }; - - export default CreateBlockModal; diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index c76edbf4..dbcb9a90 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -26,7 +26,6 @@ import 'react-toastify/dist/ReactToastify.css'; import Head from 'next/head'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; - const queryClient = new QueryClient(); const ColorModeContext = React.createContext({ toggleColorMode: () => {} }); const poppins = Poppins({ @@ -130,8 +129,8 @@ function App({ Component, pageProps }: AppProps) { {/* */} - - + + { switch (sortByAttendance) { case 'pre': sortedData.sort((a, b) => { - if (a.memberStatus === Status.DROPOUT && b.memberStatus !== Status.DROPOUT) return 1; - if (a.memberStatus !== Status.DROPOUT && b.memberStatus === Status.DROPOUT) return -1; + if ( + a.memberStatus === Status.DROPOUT && + b.memberStatus !== Status.DROPOUT + ) + return 1; + if ( + a.memberStatus !== Status.DROPOUT && + b.memberStatus === Status.DROPOUT + ) + return -1; if (a.attendance === 'present' && b.attendance === 'absent') return -1; if (a.attendance === 'absent' && b.attendance === 'present') return 1; @@ -518,8 +526,16 @@ const UserAttendanceHistory = () => { break; case 'abs': sortedData.sort((a, b) => { - if (a.memberStatus === Status.DROPOUT && b.memberStatus !== Status.DROPOUT) return 1; - if (a.memberStatus !== Status.DROPOUT && b.memberStatus === Status.DROPOUT) return -1; + if ( + a.memberStatus === Status.DROPOUT && + b.memberStatus !== Status.DROPOUT + ) + return 1; + if ( + a.memberStatus !== Status.DROPOUT && + b.memberStatus === Status.DROPOUT + ) + return -1; if (a.attendance === 'absent' && b.attendance === 'present') return -1; if (a.attendance === 'present' && b.attendance === 'absent') return 1; diff --git a/src/pages/blocks/centre.tsx b/src/pages/blocks/centre.tsx index 2ce48293..4f4df44d 100644 --- a/src/pages/blocks/centre.tsx +++ b/src/pages/blocks/centre.tsx @@ -78,19 +78,23 @@ const Blocks: React.FC = () => { // Apply sorting if (sortOrder === 'asc') { - updatedCenters = updatedCenters?.sort((a, b) => a?.name?.localeCompare(b.name)); + updatedCenters = updatedCenters?.sort((a, b) => + a?.name?.localeCompare(b.name) + ); } else if (sortOrder === 'desc') { - updatedCenters = updatedCenters?.sort((a, b) => b?.name?.localeCompare(a.name)); + updatedCenters = updatedCenters?.sort((a, b) => + b?.name?.localeCompare(a.name) + ); } // Apply center type filter if (centerType === 'regular') { - updatedCenters = updatedCenters?.filter((center) => - center?.type === 'regular' + updatedCenters = updatedCenters?.filter( + (center) => center?.type === 'regular' ); } else if (centerType === 'remote') { - updatedCenters = updatedCenters?.filter((center) => - center?.type === 'remote' + updatedCenters = updatedCenters?.filter( + (center) => center?.type === 'remote' ); } @@ -334,5 +338,4 @@ export async function getStaticProps({ locale }: any) { }; } - export default Blocks; diff --git a/src/pages/blocks/index.tsx b/src/pages/blocks/index.tsx index 43966645..b8e6de85 100644 --- a/src/pages/blocks/index.tsx +++ b/src/pages/blocks/index.tsx @@ -24,7 +24,7 @@ const Blocks: React.FC = () => { const { t } = useTranslation(); const theme = useTheme(); const router = useRouter(); - const district = 'Nagpur'; + const district = 'Nagpur'; const [anchorEl, setAnchorEl] = React.useState(null); const [openModal, setOpenModal] = useState(false); // State for modal @@ -61,7 +61,7 @@ const Blocks: React.FC = () => { }; const handleApplyFilters = () => { - let sortedBlocks = [...blocks]; + const sortedBlocks = [...blocks]; if (sortOrder === 'asc') { sortedBlocks.sort(); } else { @@ -174,7 +174,6 @@ const Blocks: React.FC = () => { { {router.push('/attendance-overview')}} + onClick={() => { + router.push('/attendance-overview'); + }} > {t('COMMON.REVIEW_ATTENDANCE')} diff --git a/src/pages/centers/index.tsx b/src/pages/centers/index.tsx index c89289da..0be267eb 100644 --- a/src/pages/centers/index.tsx +++ b/src/pages/centers/index.tsx @@ -95,7 +95,7 @@ const TeachingCenters = () => { { router.push(`/centers/${cohort.cohortId}`); - localStorage.setItem('classId', cohort.cohortId) + localStorage.setItem('classId', cohort.cohortId); }} sx={{ cursor: 'pointer', marginBottom: '20px' }} > diff --git a/src/pages/dashboard.tsx b/src/pages/dashboard.tsx index cb5a33f0..b65ae95a 100644 --- a/src/pages/dashboard.tsx +++ b/src/pages/dashboard.tsx @@ -151,7 +151,10 @@ const Dashboard: React.FC = () => { try { const response = await cohortList({ limit, page, filters }); const extractedNames = response?.results?.cohortDetails; - localStorage.setItem('parentCohortId', extractedNames?.[0].cohortData?.parentId); + localStorage.setItem( + 'parentCohortId', + extractedNames?.[0].cohortData?.parentId + ); const filteredData = extractedNames ?.map((item: any) => ({ diff --git a/src/pages/login.tsx b/src/pages/login.tsx index 60809a28..c59a7d63 100644 --- a/src/pages/login.tsx +++ b/src/pages/login.tsx @@ -119,7 +119,7 @@ const LoginPage = () => { localStorage.setItem('userId', userResponse?.userId); localStorage.setItem('state', userResponse?.state); localStorage.setItem('district', userResponse?.district); - localStorage.setItem('role', userResponse?.tenantData[0]?.roleName) + localStorage.setItem('role', userResponse?.tenantData[0]?.roleName); } } setLoading(false); diff --git a/src/pages/profile.tsx b/src/pages/profile.tsx index ed4eacd3..664aa3b1 100644 --- a/src/pages/profile.tsx +++ b/src/pages/profile.tsx @@ -109,7 +109,7 @@ const TeacherProfile = () => { const [hasInputChanged, setHasInputChanged] = React.useState(false); const [isValidationTriggered, setIsValidationTriggered] = React.useState(false); - const [userId, setUserId] = useState(null); + const [userId, setUserId] = useState(null); const handleNameFieldChange = (event: ChangeEvent) => { const { value } = event.target; @@ -141,7 +141,6 @@ const TeacherProfile = () => { } setUserId(storedUserId); } - }, []); // find Address @@ -163,28 +162,25 @@ const TeacherProfile = () => { setIsError(false); } - if (data) { - const userData = data?.result?.userData; - setUserData(userData); - setUserName(userData?.name); - const customDataFields = userData?.customFields; - setIsData(true); - if (customDataFields?.length > 0) { - setCustomFieldsData(customDataFields); + if (data) { + const userData = data?.result?.userData; + setUserData(userData); + setUserName(userData?.name); + const customDataFields = userData?.customFields; + setIsData(true); + if (customDataFields?.length > 0) { + setCustomFieldsData(customDataFields); - const unitName = getFieldValue(customDataFields, 'Unit Name'); - setUnitName(unitName); - const blockName = getFieldValue(customDataFields, 'Block Name'); - setBlockName(blockName); - - } - } else { - - setIsData(false); - console.log('No data Found'); - } - - }, [data, error, isLoading]); + const unitName = getFieldValue(customDataFields, 'Unit Name'); + setUnitName(unitName); + const blockName = getFieldValue(customDataFields, 'Block Name'); + setBlockName(blockName); + } + } else { + setIsData(false); + console.log('No data Found'); + } + }, [data, error, isLoading]); const handleClickImage = () => { fileInputRef.current && fileInputRef.current.click(); @@ -448,7 +444,7 @@ const TeacherProfile = () => { handleClose(); console.log(response.params.successmessage); - + setIsError(false); setLoading(false); } @@ -1135,9 +1131,7 @@ const TeacherProfile = () => { ) : ( - - {t('COMMON.LOADING')} - + {t('COMMON.LOADING')} )}{' '} diff --git a/src/services/MyClassDetailsService.ts b/src/services/MyClassDetailsService.ts index 641cce9d..4d5e15de 100644 --- a/src/services/MyClassDetailsService.ts +++ b/src/services/MyClassDetailsService.ts @@ -11,8 +11,11 @@ export const getMyCohortMemberList = async ({ filters, }: cohortMemberList): Promise => { const apiUrl: string = `${process.env.NEXT_PUBLIC_BASE_URL}/cohortmember/list`; - filters = { ...filters, role: Role.STUDENT, - status: [Status.DROPOUT, Status.ACTIVE]}; + filters = { + ...filters, + role: Role.STUDENT, + status: [Status.DROPOUT, Status.ACTIVE], + }; try { const response = await post(apiUrl, { limit, diff --git a/src/services/queries.ts b/src/services/queries.ts index c15c2882..da1f8fac 100644 --- a/src/services/queries.ts +++ b/src/services/queries.ts @@ -1,24 +1,22 @@ -import { useQuery } from "@tanstack/react-query"; -import { getUserDetails } from "./ProfileService"; -import { cohortList } from "./CohortServices"; -import { refetchInterval, gcTime } from "@/utils/app.constant"; +import { useQuery } from '@tanstack/react-query'; +import { getUserDetails } from './ProfileService'; +import { cohortList } from './CohortServices'; +import { refetchInterval, gcTime } from '@/utils/app.constant'; export function useProfileInfo(userId: string | string[], fieldValue: boolean) { return useQuery({ - - queryKey: ['profile', userId], + queryKey: ['profile', userId], queryFn: () => getUserDetails(userId, fieldValue), - refetchInterval: refetchInterval, - gcTime: gcTime + refetchInterval: refetchInterval, + gcTime: gcTime, }); } -export function useCohortList( limit: any, page: any, filters: any) { - return useQuery({ - queryKey: ['cohort'], - queryFn: () => cohortList({limit , page, filters}), - refetchInterval: refetchInterval, - gcTime: gcTime - }); - } - +export function useCohortList(limit: any, page: any, filters: any) { + return useQuery({ + queryKey: ['cohort'], + queryFn: () => cohortList({ limit, page, filters }), + refetchInterval: refetchInterval, + gcTime: gcTime, + }); +} diff --git a/src/styles/customTheme.tsx b/src/styles/customTheme.tsx index 7a857bc0..a7d78fd9 100644 --- a/src/styles/customTheme.tsx +++ b/src/styles/customTheme.tsx @@ -88,7 +88,6 @@ const customTheme = extendTheme({ A200: '#4d4639', A400: '#FFFFFF', A700: '#EDEDED', - }, error: { main: '#BA1A1A', @@ -112,7 +111,7 @@ const customTheme = extendTheme({ }, containedPrimary: { backgroundColor: '#FDBE16', - + border: 'none', // '&:hover': { // backgroundColor: '#FDBE161F' diff --git a/src/utils/Helper.ts b/src/utils/Helper.ts index ad11676c..60a721e9 100644 --- a/src/utils/Helper.ts +++ b/src/utils/Helper.ts @@ -203,27 +203,55 @@ export const handleKeyDown = (event: React.KeyboardEvent) => { }; export const sortAttendanceNumber = (data: any[], order: string) => { - return data.sort((a: { memberStatus: string; present_percent: string; }, b: { memberStatus: string; present_percent: string; }) => { - if (a.memberStatus === Status.DROPOUT && b.memberStatus !== Status.DROPOUT) return 1; - if (a.memberStatus !== Status.DROPOUT && b.memberStatus === Status.DROPOUT) return -1; - const aPercent = parseFloat(a.present_percent); - const bPercent = parseFloat(b.present_percent); - if (isNaN(aPercent) && isNaN(bPercent)) return 0; - if (isNaN(aPercent)) return 1; - if (isNaN(bPercent)) return -1; - return order === 'high' ? bPercent - aPercent : aPercent - bPercent; - }); + return data.sort( + ( + a: { memberStatus: string; present_percent: string }, + b: { memberStatus: string; present_percent: string } + ) => { + if ( + a.memberStatus === Status.DROPOUT && + b.memberStatus !== Status.DROPOUT + ) + return 1; + if ( + a.memberStatus !== Status.DROPOUT && + b.memberStatus === Status.DROPOUT + ) + return -1; + const aPercent = parseFloat(a.present_percent); + const bPercent = parseFloat(b.present_percent); + if (isNaN(aPercent) && isNaN(bPercent)) return 0; + if (isNaN(aPercent)) return 1; + if (isNaN(bPercent)) return -1; + return order === 'high' ? bPercent - aPercent : aPercent - bPercent; + } + ); }; export const sortClassesMissed = (data: any[], order: string) => { - return data.sort((a: { memberStatus: string; absent: string; }, b: { memberStatus: string; absent: string; }) => { - if (a.memberStatus === Status.DROPOUT && b.memberStatus !== Status.DROPOUT) return 1; - if (a.memberStatus !== Status.DROPOUT && b.memberStatus === Status.DROPOUT) return -1; - const aClassMissed = parseFloat(a.absent); - const bClassMissed = parseFloat(b.absent); - if (isNaN(aClassMissed) && isNaN(bClassMissed)) return 0; - if (isNaN(aClassMissed)) return 1; - if (isNaN(bClassMissed)) return -1; - return order === 'more' ? bClassMissed - aClassMissed : aClassMissed - bClassMissed; - }); + return data.sort( + ( + a: { memberStatus: string; absent: string }, + b: { memberStatus: string; absent: string } + ) => { + if ( + a.memberStatus === Status.DROPOUT && + b.memberStatus !== Status.DROPOUT + ) + return 1; + if ( + a.memberStatus !== Status.DROPOUT && + b.memberStatus === Status.DROPOUT + ) + return -1; + const aClassMissed = parseFloat(a.absent); + const bClassMissed = parseFloat(b.absent); + if (isNaN(aClassMissed) && isNaN(bClassMissed)) return 0; + if (isNaN(aClassMissed)) return 1; + if (isNaN(bClassMissed)) return -1; + return order === 'more' + ? bClassMissed - aClassMissed + : aClassMissed - bClassMissed; + } + ); }; diff --git a/src/utils/attendanceStats.ts b/src/utils/attendanceStats.ts index 3b541442..6d88c343 100644 --- a/src/utils/attendanceStats.ts +++ b/src/utils/attendanceStats.ts @@ -55,21 +55,17 @@ export const calculatePercentage = async ( ): Promise => { const totalStudentsCount = await getTotalStudentCount(cohortMemberRequest); const presentStudents = await getPresentStudentCount(attendanceRequest); - const result: Result = {}; - for (const date of Object.keys(presentStudents)) { const presentCount = presentStudents[date].present_students; const presentPercentage = parseFloat( ((presentCount / totalStudentsCount) * 100).toFixed(2) ); - result[date] = { present_students: presentCount, totalcount: totalStudentsCount, present_percentage: presentPercentage, }; } - return result; };