diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 80cc288..b4d0069 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -6,9 +6,12 @@
-
+
-
+
+
+
+
@@ -57,31 +60,31 @@
- {
- "keyToString": {
- "RunOnceActivity.OpenProjectViewOnStart": "true",
- "RunOnceActivity.ShowReadmeOnStart": "true",
- "RunOnceActivity.git.unshallow": "true",
- "WebServerToolWindowFactoryState": "false",
- "code.cleanup.on.save": "true",
- "git-widget-placeholder": "showings-updates",
- "last_opened_file_path": "/home/tiradoe/Projects/movie-night/web/src/types",
- "list.type.of.created.stylesheet": "CSS",
- "node.js.detected.package.eslint": "true",
- "node.js.detected.package.standard": "true",
- "node.js.detected.package.tslint": "true",
- "node.js.selected.package.eslint": "(autodetect)",
- "node.js.selected.package.standard": "",
- "node.js.selected.package.tslint": "(autodetect)",
- "nodejs_package_manager_path": "npm",
- "npm.dev.executor": "Run",
- "prettierjs.PrettierConfiguration.Package": "/home/tiradoe/Projects/movie-night/web/src/node_modules/prettier",
- "rearrange.code.on.save": "true",
- "settings.editor.selected.configurable": "settings.vue",
- "ts.external.directory.path": "/home/tiradoe/Projects/movie-night/web/src/node_modules/typescript/lib",
- "vue.rearranger.settings.migration": "true"
+
+}]]>
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 @@
-
- {{ list.name }}
-
+ {{ list.name }}
+
-
-
\ 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("/");
+ }
+ });
};
diff --git a/src/pages/admin/index.vue b/src/pages/admin/index.vue
index 9ae521a..ae83bc0 100644
--- a/src/pages/admin/index.vue
+++ b/src/pages/admin/index.vue
@@ -44,7 +44,7 @@
-
+
@@ -54,15 +54,14 @@ import AddMovie from "~/components/modal-content/AddMovie.vue";
import Search from "~/components/admin/search.vue";
import Showings from "~/components/admin/showings.vue";
import Lists from "~/components/admin/lists.vue";
-import type { MovieList } from "~/types/movielist";
import { useCookie } from "#app";
import type { Movie } from "~/types/movie";
import Modal from "~/components/Modal.vue";
-const lists = defineModel("movie-lists", { default: [] });
const modal_movie = defineModel("#movie-modal");
const movie_modal = ref | null>(null);
+const current_view = ref("search");
const closeModal = function () {
movie_modal?.value?.toggleModal();
@@ -72,6 +71,7 @@ const showModal = function (movie: Movie) {
movie_modal?.value?.toggleModal();
};
const toggleDisplay = function (element_id: string) {
+ if (element_id === current_view.value) return;
let tabs = ["search", "showings", "lists"];
tabs.forEach((value) => {
@@ -80,6 +80,7 @@ const toggleDisplay = function (element_id: string) {
document
.getElementById(element_id + "-tab")
?.classList.toggle("underline");
+ current_view.value = element_id;
} else if (!document.getElementById(value)?.classList.contains("hidden")) {
document.getElementById(value)?.classList.toggle("hidden");
document.getElementById(value + "-tab")?.classList.toggle("underline");
diff --git a/src/pages/lists/[id].vue b/src/pages/lists/[id].vue
index f59be6e..77b717d 100644
--- a/src/pages/lists/[id].vue
+++ b/src/pages/lists/[id].vue
@@ -53,7 +53,7 @@
X
@@ -83,35 +83,27 @@ const hide_scheduled = ref(false);
const getList = async function (list_id: number) {
let config = useRuntimeConfig();
- const { data, error } = await useFetch(
- `${config.public.apiURL}/lists/${list_id}`,
- {
- method: "GET",
- headers: {
- "Content-type": "application/json",
- Authorization: `Token ${useCookie("token").value}`,
- },
+ $fetch(`${config.public.apiURL}/lists/${list_id}`, {
+ method: "GET",
+ headers: {
+ "Content-type": "application/json",
+ Authorization: `Token ${useCookie("token").value}`,
},
- );
-
- if (error.value) {
- if (error.value.statusCode === 401) {
- navigateTo("/");
- }
- if (error.value.statusCode === 404) {
- alert("List not found");
- navigateTo("/lists");
- }
- } else {
- if (!data.value) {
- alert("List not found");
- navigateTo("/lists");
- } else {
- list.value = data.value;
- movies.value = data.value?.movies || [];
+ })
+ .then((data) => {
+ list.value = data;
+ movies.value = data?.movies || [];
filtered_movies.value = movies.value;
- }
- }
+ })
+ .catch((err) => {
+ if (err.statusCode === 401) {
+ navigateTo("/");
+ }
+ if (err.statusCode === 404) {
+ alert("List not found");
+ navigateTo("/lists");
+ }
+ });
};
const hideScheduled = function () {
@@ -127,7 +119,7 @@ const hideScheduled = function () {
}
};
-const removeMovie = async function (movie_id: number) {
+const removeMovie = async function (movie_id: string) {
let config = useRuntimeConfig();
let confirmed = confirm("Remove movie from list?");
diff --git a/src/pages/lists/index.vue b/src/pages/lists/index.vue
index 55ede0e..f4a38a3 100644
--- a/src/pages/lists/index.vue
+++ b/src/pages/lists/index.vue
@@ -31,21 +31,19 @@ const updateLists = async function () {
headers["Authorization"] = `Token ${useCookie("token").value}`;
}
- const { data, error } = await useFetch(
- `${config.public.apiURL}/lists`,
- {
- method: "GET",
- headers: headers,
- },
- );
-
- if (error.value) {
- if (error.value.statusCode === 401) {
- navigateTo("/");
- }
- } else {
- lists.value = data.value || [];
- }
+ await $fetch(`${config.public.apiURL}/lists`, {
+ method: "GET",
+ headers: headers,
+ })
+ .then((data) => {
+ lists.value = data || [];
+ })
+ .catch((err) => {
+ if (err.statusCode === 401) {
+ useCookie("token").value = null;
+ navigateTo("/");
+ }
+ });
};
onMounted(() => {
diff --git a/src/pages/schedule/index.vue b/src/pages/schedule/index.vue
index c373596..8cf2637 100644
--- a/src/pages/schedule/index.vue
+++ b/src/pages/schedule/index.vue
@@ -61,6 +61,8 @@