diff --git a/frontend/src/api/loadCalendar.ts b/frontend/src/api/loadCalendar.ts index 6ec03aa..d833c4d 100644 --- a/frontend/src/api/loadCalendar.ts +++ b/frontend/src/api/loadCalendar.ts @@ -6,9 +6,13 @@ export async function getCalender(token: string): Promise { method: "GET", }); - return await fetch(request) - .then((response) => { - return response.json(); - }) - .then((calendarResponse: Calendar) => calendarResponse.modules); + return await fetch(request).then((response) => { + if (response.ok) { + return response + .json() + .then((calendarResponse: Calendar) => calendarResponse.modules); + } else { + return []; + } + }); } diff --git a/frontend/src/i18n/translations/de.json b/frontend/src/i18n/translations/de.json index c4f54d6..d059bce 100644 --- a/frontend/src/i18n/translations/de.json +++ b/frontend/src/i18n/translations/de.json @@ -49,7 +49,8 @@ "invalidToken": "Ungültiger Token", "headline": "Bearbeite deinen HTWKalender", "subTitle": "Füge deinen Link oder Token ein um den Kalender zu bearbeiten", - "loadCalendar": "Kalender laden" + "loadCalendar": "Kalender laden", + "noCalendarFound": "Keinen Kalender gefunden" }, "additionalModules": { "subTitle": "Füge weitere Module hinzu die nicht in deinem Studiengang enthalten sind.", diff --git a/frontend/src/i18n/translations/en.json b/frontend/src/i18n/translations/en.json index 5107b07..cf7d08a 100644 --- a/frontend/src/i18n/translations/en.json +++ b/frontend/src/i18n/translations/en.json @@ -49,7 +49,8 @@ "invalidToken": "invalid token", "headline": "edit your HTWKalender", "subTitle": "please enter your link or calendar token", - "loadCalendar": "load calendar" + "loadCalendar": "load calendar", + "noCalendarFound": "no calendar found" }, "additionalModules": { "subTitle": "Select additional Modules that are not listed in the regular semester for your Course", diff --git a/frontend/src/view/EditCalendarView.vue b/frontend/src/view/EditCalendarView.vue index 50a2de5..ae80c71 100644 --- a/frontend/src/view/EditCalendarView.vue +++ b/frontend/src/view/EditCalendarView.vue @@ -46,14 +46,22 @@ function loadCalendar(): void { moduleStore().removeAllModules(); tokenStore().setToken(token.value); - getCalender(token.value).then((data) => { - data.forEach((module) => { - moduleStore().addModule(module); - }); - modules.value = data; + getCalender(token.value).then((data: Module[]) => { + if (data.length > 0) { + data.forEach((module) => { + moduleStore().addModule(module); + }); + modules.value = data; + router.push("/edit-additional-modules"); + } else { + toast.add({ + severity: "error", + summary: t("editCalendarView.error"), + detail: t("editCalendarView.noCalendarFound"), + life: 3000, + }); + } }); - - router.push("/edit-additional-modules"); }