diff --git a/src/calendar.js b/src/calendar.js index 8b0aca2..236aeb8 100644 --- a/src/calendar.js +++ b/src/calendar.js @@ -1,3 +1,5 @@ +import STATIC_LOCATIONS from './static-ens-locations.json'; + // https://stackoverflow.com/a/35970186 function invertColor(hex) { if (hex.indexOf('#') === 0) { @@ -231,6 +233,18 @@ class Calendar { } } +function findLocationId(location) { + // TODO: Perform ad-hoc patches of location so it can be better associated. + // Strip '(Jourdan)' + // Relocate room number + + const result = Object.entries(STATIC_LOCATIONS).find(([building, rooms]) => rooms.includes(location)); + + if (result === undefined) return undefined; + const [building, _] = result; + return `${building}-${location}`; +} + function fcEventFromjCalEvent(cal) { return function (evt) { const start = new Date(evt.dtstart) @@ -249,6 +263,10 @@ function fcEventFromjCalEvent(cal) { fcEvent.description = evt.description fcEvent.location = evt.location || cal.default_location + if (fcEvent.location) { + fcEvent.resourceId = findLocationId(fcEvent.location); + } + if (evt.status) { fcEvent.status = evt.status fcEvent.classNames = [`st-${evt.status.toLowerCase()}`]