mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-08-04 02:39:14 +02:00
Merge pull request #80 from HTWK-Leipzig/79-edit-calender-loading-block
fix:#79 added check for token and response feedback with toast
This commit is contained in:
@@ -6,9 +6,13 @@ export async function getCalender(token: string): Promise<Module[]> {
|
||||
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 [];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -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.",
|
||||
|
@@ -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",
|
||||
|
@@ -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");
|
||||
}
|
||||
</script>
|
||||
|
||||
|
Reference in New Issue
Block a user