From cf07db861f764740926d59d6d4b8895b12f51644 Mon Sep 17 00:00:00 2001 From: masterElmar <18119527+masterElmar@users.noreply.github.com> Date: Mon, 20 Nov 2023 21:11:42 +0100 Subject: [PATCH 1/2] fix:#79 added check for token and response feedback with toast --- frontend/src/api/loadCalendar.ts | 7 +++++-- frontend/src/i18n/translations/de.json | 3 ++- frontend/src/i18n/translations/en.json | 3 ++- frontend/src/view/EditCalendarView.vue | 21 +++++++++++++++------ 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/frontend/src/api/loadCalendar.ts b/frontend/src/api/loadCalendar.ts index 6ec03aa..0a665fe 100644 --- a/frontend/src/api/loadCalendar.ts +++ b/frontend/src/api/loadCalendar.ts @@ -8,7 +8,10 @@ export async function getCalender(token: string): Promise { return await fetch(request) .then((response) => { - return response.json(); + if( response.ok){ + return response.json().then((calendarResponse: Calendar) => calendarResponse.modules) + } else { + return []; + } }) - .then((calendarResponse: Calendar) => calendarResponse.modules); } diff --git a/frontend/src/i18n/translations/de.json b/frontend/src/i18n/translations/de.json index 4dd8efa..672fc61 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 641d5b9..2f55add 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 e0fa2dc..a0b9b9e 100644 --- a/frontend/src/view/EditCalendarView.vue +++ b/frontend/src/view/EditCalendarView.vue @@ -46,14 +46,23 @@ 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"); } From 3814a4712de8d3c52aec2dbd337adb4db63fd3db Mon Sep 17 00:00:00 2001 From: masterElmar <18119527+masterElmar@users.noreply.github.com> Date: Mon, 20 Nov 2023 21:13:27 +0100 Subject: [PATCH 2/2] fix:#79 lint and format --- frontend/src/api/loadCalendar.ts | 17 +- frontend/src/components/FaqPage.vue | 211 ++++++++++++------ frontend/src/components/ModuleInformation.vue | 37 ++- frontend/src/i18n/translations/de.json | 14 +- frontend/src/view/AdditionalModules.vue | 28 ++- frontend/src/view/EditCalendarView.vue | 13 +- frontend/src/view/ImprintPage.vue | 2 +- frontend/src/view/PrivacyPolicy.vue | 2 +- 8 files changed, 215 insertions(+), 109 deletions(-) diff --git a/frontend/src/api/loadCalendar.ts b/frontend/src/api/loadCalendar.ts index 0a665fe..d833c4d 100644 --- a/frontend/src/api/loadCalendar.ts +++ b/frontend/src/api/loadCalendar.ts @@ -6,12 +6,13 @@ export async function getCalender(token: string): Promise { method: "GET", }); - return await fetch(request) - .then((response) => { - if( response.ok){ - return response.json().then((calendarResponse: Calendar) => calendarResponse.modules) - } else { - return []; - } - }) + return await fetch(request).then((response) => { + if (response.ok) { + return response + .json() + .then((calendarResponse: Calendar) => calendarResponse.modules); + } else { + return []; + } + }); } diff --git a/frontend/src/components/FaqPage.vue b/frontend/src/components/FaqPage.vue index cdb8efa..9296436 100644 --- a/frontend/src/components/FaqPage.vue +++ b/frontend/src/components/FaqPage.vue @@ -1,141 +1,216 @@ - +