Skip to content

Commit

Permalink
Issue #PS-1626 feat: event list for month view
Browse files Browse the repository at this point in the history
  • Loading branch information
suvarnakale committed Aug 8, 2024
1 parent aaf6bae commit e66688a
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions src/pages/eventMonthView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,35 @@ const eventMonthView = () => {
useEffect(() => {
const getSessionsData = async () => {
try {
const date = new Date();
const today = shortDateFormat(selectedDate);
let cohortId;
if (typeof window !== 'undefined' && window.localStorage) {
cohortId = localStorage.getItem('classId') || '';
}
const limit = 0;
const offset = 0;
const filters = {
date: today,
cohortId: cohortId,
status: ['live'],
};
const response = await getEventList({ limit, offset, filters });
let sessionArray: any[] = [];
let extraSessionArray: any[] = [];
if (response?.events.length > 0) {
response?.events.forEach((event: any) => {
if (event.isRecurring) {
sessionArray.push(event);
}
if (!event.isRecurring) {
extraSessionArray.push(event);
}
});
if (cohortId !== '') {
const limit = 0;
const offset = 0;
const filters = {
date: today,
cohortId: cohortId,
status: ['live'],
};
const response = await getEventList({ limit, offset, filters });
let sessionArray: any[] = [];
let extraSessionArray: any[] = [];
if (response?.events.length > 0) {
response?.events.forEach((event: any) => {
if (event.isRecurring) {
sessionArray.push(event);
}
if (!event.isRecurring) {
extraSessionArray.push(event);
}
});
}
setSessions(sessionArray);
setExtraSessions(extraSessionArray);
}
setSessions(sessionArray);
setExtraSessions(extraSessionArray);
} catch (error) {
setSessions([]);
setExtraSessions([]);
Expand Down

0 comments on commit e66688a

Please sign in to comment.