Skip to content

Commit

Permalink
Merge pull request #92 from Rushikesh-Sonawane99/release-1.0.0
Browse files Browse the repository at this point in the history
Issue #PS-1462 chore: Resolved attendance list view issue due to time zone of user creation
  • Loading branch information
itsvick authored Aug 5, 2024
2 parents 3980191 + 6462fee commit 14afd7d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 40 deletions.
79 changes: 42 additions & 37 deletions src/pages/attendance-history.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -316,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);
// 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);
}
// while (currentDate <= lastDate) {
// datesArray.push(shortDateFormat(currentDate));
// currentDate.setDate(currentDate.getDate() + 1);
// }

return datesArray;
};
// 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('');
Expand Down
6 changes: 3 additions & 3 deletions src/pages/user-profile/[userId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 14afd7d

Please sign in to comment.