diff --git a/rogue-thi-app/components/cards/TimetableCard.jsx b/rogue-thi-app/components/cards/TimetableCard.jsx index 77203e11..7bc27e9e 100644 --- a/rogue-thi-app/components/cards/TimetableCard.jsx +++ b/rogue-thi-app/components/cards/TimetableCard.jsx @@ -82,11 +82,13 @@ export default function TimetableCard () { ) }))} {(timetable && timetable.length === 0) && - {t('timetable.text.noLectures')} + + {t('timetable.text.noLectures')} + } {(timetableError && - {t('timetable.text.error')}) - } + {t('timetable.text.error')} + )} diff --git a/rogue-thi-app/lib/backend-utils/timetable-utils.js b/rogue-thi-app/lib/backend-utils/timetable-utils.js index e30fa933..ca13639d 100644 --- a/rogue-thi-app/lib/backend-utils/timetable-utils.js +++ b/rogue-thi-app/lib/backend-utils/timetable-utils.js @@ -76,6 +76,15 @@ export function getTimetableGaps (timetable) { export async function getFriendlyTimetable (date, detailed) { const { timetable } = await API.getTimetable(date, detailed) + /** + * During the semester break, the API returns an null array ('[null]'). + * To prevent errors for the room suggestions or the timetable view, we return an empty array. + */ + if (timetable.every(x => x === null)) { + console.error('API returned null array for timetable!') + return [] + } + return timetable .flatMap(day => Object.values(day.hours)