Compare commits

..

No commits in common. "03a3e5ea01bbb477af7c6c5c827d23e4a85b5bed" and "4c6d35f8d876cec6746e90a088663fec721f3c8a" have entirely different histories.

3 changed files with 4 additions and 49 deletions

3
.idea/workspace.xml generated
View file

@ -6,8 +6,7 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="5e320804-68c9-4504-97d5-d421de3438b2" name="Changes" comment=""> <list default="true" id="5e320804-68c9-4504-97d5-d421de3438b2" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/components/modal-content/ShowMovie.vue" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/modal-content/ShowMovie.vue" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/components/LoadingIcon.vue" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/LoadingIcon.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/lists/[id].vue" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/lists/[id].vue" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />

View file

@ -1,7 +1,6 @@
<template> <template>
<div class="sm:m-5 p-10 movie-card neon-border"> <div class="sm:m-5 p-10 movie-card neon-border">
<div> <div>
<LoadingIcon v-if="updating" />
<h2 class="text-xl pb-3 text-center sm:text-left"> <h2 class="text-xl pb-3 text-center sm:text-left">
{{ movie.title }} ({{ movie.year }}) {{ movie.title }} ({{ movie.year }})
</h2> </h2>
@ -19,10 +18,6 @@
class="mt-5" class="mt-5"
@close-modal="$emit('close-modal')" @close-modal="$emit('close-modal')"
/> />
<button class="my-10 btn p-2 rounded" @click="updateMovie">
Refresh movie
</button>
</div> </div>
</div> </div>
</div> </div>
@ -32,14 +27,10 @@
<script lang="ts" setup> <script lang="ts" setup>
import ScheduleMovie from "~/components/forms/ScheduleMovie.vue"; import ScheduleMovie from "~/components/forms/ScheduleMovie.vue";
const props = defineProps(["movie", "updating"]); const props = defineProps(["movie"]);
const emits = defineEmits(["close-modal", "update-movie"]); const emits = defineEmits(["close-modal"]);
const logged_in = ref(false); const logged_in = ref(false);
const updateMovie = function () {
emits("update-movie");
};
onMounted(() => { onMounted(() => {
const token = useCookie("token").value; const token = useCookie("token").value;
if (token) { if (token) {

View file

@ -5,9 +5,7 @@
<ShowMovie <ShowMovie
v-if="modal_movie" v-if="modal_movie"
:movie="modal_movie" :movie="modal_movie"
:updating="updating"
@close-modal="closeModal" @close-modal="closeModal"
@update-movie="updateMovie(modal_movie)"
></ShowMovie> ></ShowMovie>
</Modal> </Modal>
<h2 class="text-xl font-bold pb-5">{{ list.name }}</h2> <h2 class="text-xl font-bold pb-5">{{ list.name }}</h2>
@ -40,7 +38,7 @@
> >
<li <li
v-for="movie in filtered_movies" v-for="movie in filtered_movies"
:key="movie.poster" :key="movie.id"
class="rounded movie-card neon-border" class="rounded movie-card neon-border"
> >
<!-- POSTER --> <!-- POSTER -->
@ -73,7 +71,6 @@ import type { MovieList } from "~/types/movielist";
import type { Movie } from "~/types/movie"; import type { Movie } from "~/types/movie";
import Modal from "~/components/Modal.vue"; import Modal from "~/components/Modal.vue";
import { useCookie } from "#app"; import { useCookie } from "#app";
import { $fetch } from "ofetch";
const list_id = ref(0); const list_id = ref(0);
const list = defineModel<MovieList>("movie_list", { default: [] }); const list = defineModel<MovieList>("movie_list", { default: [] });
@ -171,38 +168,6 @@ const removeMovie = async function (movie_id: string) {
} }
}; };
const updating = ref(false);
const updateMovie = async function (movie: Movie) {
let config = useRuntimeConfig();
updating.value = true;
$fetch<Movie>(`${config.public.apiURL}/movies/${movie.id}/`, {
method: "PUT",
headers: {
"Content-type": "application/json",
Authorization: `Token ${useCookie("token").value}`,
},
body: JSON.stringify(movie),
})
.then((data) => {
modal_movie.value = data || [];
movies.value = movies.value.map((movie) => {
return movie.id === data.id ? data : movie;
});
filtered_movies.value = movies.value;
updating.value = false;
})
.catch((err) => {
if (err.statusCode === 401) {
navigateTo("/");
}
if (err.statusCode === 404) {
alert("Unable to update movie");
}
updating.value = false;
});
};
const filterMovies = function () { const filterMovies = function () {
if (!movie_query) { if (!movie_query) {
filtered_movies.value = movies.value; filtered_movies.value = movies.value;