From 1e6e7d950a3aae77637575c4a20be40fc3645f4a Mon Sep 17 00:00:00 2001 From: Rushikesh-Sonawane99 Date: Mon, 5 Aug 2024 00:36:47 +0530 Subject: [PATCH 1/3] Issue #PS-1462 chore: Resolved attendance list view issue due to time zone of user creation --- src/pages/attendance-history.tsx | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/pages/attendance-history.tsx b/src/pages/attendance-history.tsx index 1bae5d92..9fc9df00 100644 --- a/src/pages/attendance-history.tsx +++ b/src/pages/attendance-history.tsx @@ -178,18 +178,23 @@ const UserAttendanceHistory = () => { page, filters, }); - const resp = response?.result?.userDetails; + const resp = response?.result?.userDetails || []; if (resp) { - const nameUserIdArray = resp?.map((entry: any) => ({ - userId: entry.userId, - name: toPascalCase(entry.name), - memberStatus: entry.status,createdAt: entry.createdAt, - })) - .filter((member: { createdAt: string | number | Date }) => { - const createdAt = new Date(member.createdAt); - return createdAt <= selectedDate; - }); + let selectedDateStart = new Date(selectedDate); + selectedDateStart.setHours(0, 0, 0, 0); + let nameUserIdArray = resp + .filter((entry: any) => { + const createdAtDate = new Date(entry.createdAt); + createdAtDate.setHours(0, 0, 0, 0); + return createdAtDate <= selectedDateStart; + }) + .map((entry: any) => ({ + userId: entry.userId, + name: toPascalCase(entry.name), + memberStatus: entry.status, + createdAt: entry.createdAt, + })); if (nameUserIdArray && (selectedDate || currentDate)) { const userAttendanceStatusList = async () => { const attendanceStatusData: AttendanceStatusListProps = { From 2f5e272dd675d1930d0a4b07e99ffcc2ec04e822 Mon Sep 17 00:00:00 2001 From: Rushikesh-Sonawane99 Date: Mon, 5 Aug 2024 00:46:25 +0530 Subject: [PATCH 2/3] Issue #000 chore: Optimised code --- src/pages/attendance-history.tsx | 56 ++++++++++++++++---------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/pages/attendance-history.tsx b/src/pages/attendance-history.tsx index 9fc9df00..b594ae08 100644 --- a/src/pages/attendance-history.tsx +++ b/src/pages/attendance-history.tsx @@ -321,40 +321,40 @@ const UserAttendanceHistory = () => { }; - const getAllDatesInRange = (startDate: string, endDate: string): string[] => { - const datesArray: string[] = []; - const currentDate = new Date(startDate); - const lastDate = new Date(endDate); - - while (currentDate <= lastDate) { - datesArray.push(shortDateFormat(currentDate)); - currentDate.setDate(currentDate.getDate() + 1); - } + // const getAllDatesInRange = (startDate: string, endDate: string): string[] => { + // const datesArray: string[] = []; + // const currentDate = new Date(startDate); + // const lastDate = new Date(endDate); - return datesArray; - }; + // while (currentDate <= lastDate) { + // datesArray.push(shortDateFormat(currentDate)); + // currentDate.setDate(currentDate.getDate() + 1); + // } + + // return datesArray; + // }; const handleSelectedDateChange = (date: Date | Date[] | null) => { setSelectedDate(date as Date); }; - const handleUpdate = async (date: string, status: string) => { - const trimmedContextId = classId.trim(); - if (userId && trimmedContextId) { - const attendanceData: AttendanceParams = { - attendanceDate: date, - attendance: status, - userId, - contextId: trimmedContextId, - }; - setLoading(true); - } - }; - - function getStateByCohortId(cohortId: any) { - const cohort = cohortsData?.find((item) => item.cohortId === cohortId); - return cohort ? cohort?.state : null; - } + // const handleUpdate = async (date: string, status: string) => { + // const trimmedContextId = classId.trim(); + // if (userId && trimmedContextId) { + // const attendanceData: AttendanceParams = { + // attendanceDate: date, + // attendance: status, + // userId, + // contextId: trimmedContextId, + // }; + // setLoading(true); + // } + // }; + + // function getStateByCohortId(cohortId: any) { + // const cohort = cohortsData?.find((item) => item.cohortId === cohortId); + // return cohort ? cohort?.state : null; + // } const handleSearchClear = () => { setSearchWord(''); From 6462fee32b5028c2a0a4c4c357529567e2b3d5a2 Mon Sep 17 00:00:00 2001 From: Rushikesh-Sonawane99 Date: Mon, 5 Aug 2024 00:50:36 +0530 Subject: [PATCH 3/3] Issue #000 chore: Commented unwanted code --- src/pages/user-profile/[userId].tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/user-profile/[userId].tsx b/src/pages/user-profile/[userId].tsx index 3daa7745..000387e8 100644 --- a/src/pages/user-profile/[userId].tsx +++ b/src/pages/user-profile/[userId].tsx @@ -269,9 +269,9 @@ const TeacherProfile = () => { console.log(`mergedProfileData`, mergedProfileData); if (mergedProfileData) { setUserData(mergedProfileData?.fields); - const nameField = mergedProfileData.fields.find( - (field: { name: string }) => field.name === 'name' - ); + // const nameField = mergedProfileData.fields.find( + // (field: { name: string }) => field.name === 'name' + // ); const customDataFields = mergedProfileData?.fields; setIsData(true);