From 411ff72b68904f9383bfa7df344ac8838ab133f0 Mon Sep 17 00:00:00 2001 From: TTPL-RT-52 Date: Thu, 30 May 2024 13:06:02 +0530 Subject: [PATCH] Issue PS-652 fix:scrolling issue when user uses the scroll up/down button --- src/components/Header.tsx | 39 ++++-- src/components/MenuDrawer.tsx | 12 +- src/pages/dashboard.tsx | 218 +++++++++++++++++----------------- src/styles/globals.css | 10 ++ 4 files changed, 155 insertions(+), 124 deletions(-) diff --git a/src/components/Header.tsx b/src/components/Header.tsx index c7bb3447..1757dbb7 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -127,19 +127,28 @@ const Header: React.FC = () => { height="auto" boxShadow="0px 1px 3px 0px #0000004D" > - - - - - logo router.push('/dashboard')} - style={{ cursor: 'pointer' }} + + + + logo router.push('/dashboard')} + style={{ cursor: 'pointer' }} + /> { flexDirection={'column'} mt={'0.5rem'} > - + -
+
void; } + const MenuDrawer: React.FC = ({ toggleDrawer, open, @@ -49,6 +50,12 @@ const MenuDrawer: React.FC = ({ } }; + const navigateToDashboard = () => { + router.push('/dashboard'); + }; + + const isDashboard = router.pathname === '/dashboard'; + return ( = ({ width: '100%', display: 'flex', justifyContent: 'flex-start', - background: theme.palette.primary.main, + background: isDashboard + ? theme.palette.primary.main + : 'rgba(29, 27, 32, 0.12)', padding: '16px !important', marginTop: '15px', color: '#2E1500', @@ -144,6 +153,7 @@ const MenuDrawer: React.FC = ({ }, }} startIcon={} + onClick={navigateToDashboard} > {t('DASHBOARD.DASHBOARD')} diff --git a/src/pages/dashboard.tsx b/src/pages/dashboard.tsx index 55173edd..c61f5d57 100644 --- a/src/pages/dashboard.tsx +++ b/src/pages/dashboard.tsx @@ -165,126 +165,124 @@ const Dashboard: React.FC = () => { const getCohortMemberList = async () => { setLoading(true); try { - if (classId) { - const limit = 300; - const page = 0; - const filters = { cohortId: classId }; - const response = await getMyCohortMemberList({ - limit, - page, - filters, - }); - const resp = response?.data?.userDetails; - - if (resp) { - const nameUserIdArray = resp?.map((entry: any) => ({ - userId: entry.userId, - name: toPascalCase(entry.name), - })); - console.log('name..........', nameUserIdArray); - if (nameUserIdArray && (selectedDate || currentDate)) { - const userAttendanceStatusList = async () => { - const attendanceStatusData: AttendanceStatusListProps = { - limit: 300, - page: 0, - filters: { - fromDate: selectedDate || currentDate, - toDate: selectedDate || currentDate, - contextId: classId, - }, + // if (classId) { + const limit = 300; + const page = 0; + const filters = { cohortId: classId }; + const response = await getMyCohortMemberList({ + limit, + page, + filters, + }); + const resp = response?.data?.userDetails; + + if (resp) { + const nameUserIdArray = resp?.map((entry: any) => ({ + userId: entry.userId, + name: toPascalCase(entry.name), + })); + console.log('name..........', nameUserIdArray); + if (nameUserIdArray && (selectedDate || currentDate)) { + const userAttendanceStatusList = async () => { + const attendanceStatusData: AttendanceStatusListProps = { + limit: 300, + page: 0, + filters: { + fromDate: selectedDate || currentDate, + toDate: selectedDate || currentDate, + contextId: classId, + }, + }; + const res = await attendanceStatusList(attendanceStatusData); + const response = res?.data?.attendanceList; + console.log('attendanceStatusList', response); + if (nameUserIdArray && response) { + const getUserAttendanceStatus = ( + nameUserIdArray: any[], + response: any[] + ) => { + const userAttendanceArray: { + userId: any; + attendance: any; + }[] = []; + + nameUserIdArray.forEach((user) => { + const userId = user.userId; + const attendance = response.find( + (status) => status.userId === userId + ); + userAttendanceArray.push({ + userId, + attendance: attendance?.attendance + ? attendance.attendance + : '', + }); + }); + return userAttendanceArray; }; - const res = await attendanceStatusList(attendanceStatusData); - const response = res?.data?.attendanceList; - console.log('attendanceStatusList', response); - if (nameUserIdArray && response) { - const getUserAttendanceStatus = ( - nameUserIdArray: any[], - response: any[] - ) => { - const userAttendanceArray: { - userId: any; - attendance: any; + const userAttendanceArray = getUserAttendanceStatus( + nameUserIdArray, + response + ); + console.log('userAttendanceArray', userAttendanceArray); + + if (nameUserIdArray && userAttendanceArray) { + const mergeArrays = ( + nameUserIdArray: { userId: string; name: string }[], + userAttendanceArray: { + userId: string; + attendance: string; + }[] + ): { + userId: string; + name: string; + attendance: string; + }[] => { + const newArray: { + userId: string; + name: string; + attendance: string; }[] = []; - nameUserIdArray.forEach((user) => { const userId = user.userId; - const attendance = response.find( - (status) => status.userId === userId + const attendanceEntry = userAttendanceArray.find( + (entry) => entry.userId === userId ); - userAttendanceArray.push({ - userId, - attendance: attendance?.attendance - ? attendance.attendance - : '', - }); + if (attendanceEntry) { + newArray.push({ + userId, + name: user.name, + attendance: attendanceEntry.attendance, + }); + } }); - return userAttendanceArray; + if (newArray.length != 0) { + // newArray = newArray.filter(item => item.name); + setCohortMemberList(newArray); + setPresentCount( + newArray.filter((user) => user.attendance === 'present') + .length + ); + setAbsentCount( + newArray.filter((user) => user.attendance === 'absent') + .length + ); + setNumberOfCohortMembers(newArray?.length); + } else { + setCohortMemberList(nameUserIdArray); + setNumberOfCohortMembers(nameUserIdArray?.length); + } + return newArray; }; - const userAttendanceArray = getUserAttendanceStatus( - nameUserIdArray, - response - ); - console.log('userAttendanceArray', userAttendanceArray); - - if (nameUserIdArray && userAttendanceArray) { - const mergeArrays = ( - nameUserIdArray: { userId: string; name: string }[], - userAttendanceArray: { - userId: string; - attendance: string; - }[] - ): { - userId: string; - name: string; - attendance: string; - }[] => { - const newArray: { - userId: string; - name: string; - attendance: string; - }[] = []; - nameUserIdArray.forEach((user) => { - const userId = user.userId; - const attendanceEntry = userAttendanceArray.find( - (entry) => entry.userId === userId - ); - if (attendanceEntry) { - newArray.push({ - userId, - name: user.name, - attendance: attendanceEntry.attendance, - }); - } - }); - if (newArray.length != 0) { - // newArray = newArray.filter(item => item.name); - setCohortMemberList(newArray); - setPresentCount( - newArray.filter( - (user) => user.attendance === 'present' - ).length - ); - setAbsentCount( - newArray.filter( - (user) => user.attendance === 'absent' - ).length - ); - setNumberOfCohortMembers(newArray?.length); - } else { - setCohortMemberList(nameUserIdArray); - setNumberOfCohortMembers(nameUserIdArray?.length); - } - return newArray; - }; - mergeArrays(nameUserIdArray, userAttendanceArray); - } + mergeArrays(nameUserIdArray, userAttendanceArray); } - setLoading(false); - }; - userAttendanceStatusList(); - } + } + setLoading(false); + }; + userAttendanceStatusList(); } } + // } } catch (error) { console.error('Error fetching cohort list:', error); setLoading(false); diff --git a/src/styles/globals.css b/src/styles/globals.css index f11e6d78..50b7de3e 100644 --- a/src/styles/globals.css +++ b/src/styles/globals.css @@ -14,6 +14,7 @@ body { margin: 0 !important; padding: 0 !important; box-sizing: border-box; + background-color: white; } .drawer-select div div { @@ -527,3 +528,12 @@ main { right: 360px; } } */ + +.menuSvg path { + width: 36px; + height: 24px; +} +.accIcon path { + width: 20; + height: 20px; +}