diff --git a/src/components/admin/lists.vue b/src/components/admin/lists.vue index afdcc2c..6925bcb 100644 --- a/src/components/admin/lists.vue +++ b/src/components/admin/lists.vue @@ -3,90 +3,98 @@
- +
- - \ No newline at end of file + diff --git a/src/components/admin/showings.vue b/src/components/admin/showings.vue index 711c64b..07796c1 100644 --- a/src/components/admin/showings.vue +++ b/src/components/admin/showings.vue @@ -26,6 +26,7 @@ import type { Showing } from "~/types/showing"; import { useCookie } from "#app"; import type { Schedule } from "~/types/schedule"; +import { $fetch } from "ofetch"; const showings = defineModel("showings", { default: [] }); const previous_showings = defineModel("previous_showings", { @@ -86,33 +87,27 @@ const getShowings = function (previous = false) { let params = ""; if (previous) params = "?previous=true"; - const { data, error } = useFetch( - `${config.public.apiURL}/schedules/1${params}`, - { - method: "GET", - headers: { - "Content-type": "application/json", - Authorization: `Token ${useCookie("token").value}`, - }, + $fetch(`${config.public.apiURL}/schedules/1${params}`, { + method: "GET", + headers: { + "Content-type": "application/json", + Authorization: `Token ${useCookie("token").value}`, }, - ); - - if (error.value) { - if (error.value.statusCode === 401) { - alert("Unauthorized"); - } - } else { - if (!data.value) { - alert("No showings found for schedule."); - } else { + }) + .then((data) => { if (previous) { got_previous.value = true; - previous_showings.value = data.value.showings; + previous_showings.value = data.showings; } else { - showings.value = data.value.showings; + showings.value = data.showings; } - } - } + }) + .catch((err) => { + if (err.statusCode === 401) { + useCookie("token").value = null; + navigateTo("/"); + } + }); };