-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
21 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
Scripts specific to events, ie not dots | ||
*/ | ||
|
||
// const { addDays } = require("date-fns"); | ||
|
||
const calendarIds = [ | ||
"[email protected]", // CCPA | ||
"a71ff6b63e1709ae2bfbcada2b3b64ebeb1f7f5e30787b2bb059725fa17b7b2b@group.calendar.google.com", // Free museums - https://github.com/ccpa-ousd/opps-cal-hs | ||
|
@@ -42,18 +44,6 @@ document.addEventListener("DOMContentLoaded", () => { | |
// in the same loop, fetch recurring instances | ||
// and set eventType for calendars like 'opportunity' | ||
for (let event of gCalevents) { | ||
if ( | ||
calendarId == | ||
"a71ff6b63e1709ae2bfbcada2b3b64ebeb1f7f5e30787b2bb059725fa17b7b2b@group.calendar.google.com" | ||
) { | ||
gCalevents[i].eventType = "opportunity"; | ||
} | ||
if ( | ||
calendarId == | ||
"e5c502978d4582e2e7b304e8197120672739ed245f730fc938e64c24949e000e@group.calendar.google.com" | ||
) { | ||
gCalevents[i].eventType = "studentActivity"; | ||
} | ||
if (event.recurrence) { | ||
let instancesUrl = `https://www.googleapis.com/calendar/v3/calendars/${calendarId}/events/${event.id}/instances?timeMin=${timeMin}&timeMax=${timeMax}&key=${gCalkey}&timeZone=${timezone}`; | ||
let instancesResponse = await fetch(instancesUrl); | ||
|
@@ -74,15 +64,33 @@ document.addEventListener("DOMContentLoaded", () => { | |
gCalActiveEvents = gCalevents.filter( | ||
(item) => item.status !== "cancelled" | ||
); | ||
|
||
// Adjust for CCPA Public Calendar events which are missing timezones and dateTimes | ||
// That missing data causes its events to show up 1 day early | ||
for (item of combinedGCalEvents) { | ||
if ( | ||
calendarId == | ||
"[email protected]" && | ||
item.start.timeZone != "America/Los_Angeles" && | ||
item.start.dateTime == undefined | ||
) { | ||
item.start.timeZone = "America/Los_Angeles"; | ||
item.start.dateTime = item.start.date + " 0:00:00"; | ||
} | ||
} | ||
// push each event (from each calendar) into the combinedGCalEvents array | ||
for (let i = 0; i < gCalActiveEvents.length; i++) { | ||
if ( | ||
calendarId == | ||
"a71ff6b63e1709ae2bfbcada2b3b64ebeb1f7f5e30787b2bb059725fa17b7b2b@group.calendar.google.com" | ||
) { | ||
gCalActiveEvents[i].eventType = "opportunity"; | ||
} else if ( | ||
calendarId == | ||
"e5c502978d4582e2e7b304e8197120672739ed245f730fc938e64c24949e000e@group.calendar.google.com" | ||
) { | ||
gCalevents[i].eventType = "studentActivity"; | ||
} | ||
|
||
combinedGCalEvents.push(gCalActiveEvents[i]); | ||
} | ||
} | ||
|
@@ -137,7 +145,6 @@ document.addEventListener("DOMContentLoaded", () => { | |
// then sort them by date | ||
for (let event of currentSY.dates) { | ||
combinedAllEvents.push(event); | ||
console.log(event); | ||
} | ||
for (let event of combinedGCalEvents) { | ||
combinedAllEvents.push(event); | ||
|