updated search to use typescript and composition api
This commit is contained in:
parent
2187c2637b
commit
6b4617cf3d
6 changed files with 226 additions and 159 deletions
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<div v-if="list_id !== 0" class="p-5 sm:p-0">
|
||||
<Modal>
|
||||
<Modal ref="movie_modal">
|
||||
<ShowMovie v-if="modal_movie" :movie="modal_movie"></ShowMovie>
|
||||
</Modal>
|
||||
<h2 class="text-xl font-bold pb-5">{{ list.name }}</h2>
|
||||
|
@ -64,6 +64,9 @@ import ShowMovie from "~/components/modal-content/ShowMovie.vue";
|
|||
import "lazysizes";
|
||||
import type { MovieList } from "~/types/movielist";
|
||||
import type { Movie } from "~/types/movie";
|
||||
import Modal from "~/components/Modal.vue";
|
||||
|
||||
const movie_modal = ref<InstanceType<typeof Modal> | null>(null);
|
||||
|
||||
const list_id = ref(0);
|
||||
const list = defineModel<MovieList>("movie_list", { default: [] });
|
||||
|
@ -176,7 +179,7 @@ const filterMovies = function () {
|
|||
|
||||
const showModal = function (movie: Movie) {
|
||||
modal_movie.value = movie;
|
||||
document.getElementById("movie-modal")?.classList.remove("hidden");
|
||||
movie_modal.value?.toggleModal();
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
|
|
|
@ -18,18 +18,24 @@
|
|||
|
||||
<script lang="ts" setup>
|
||||
import type { MovieList } from "~/types/movielist";
|
||||
import { useCookie } from "#app";
|
||||
|
||||
const lists = defineModel<MovieList[]>("movie_list", { default: [] });
|
||||
const updateLists = async function () {
|
||||
let config = useRuntimeConfig();
|
||||
let headers: any = {
|
||||
"Content-type": "application/json",
|
||||
};
|
||||
|
||||
if (typeof useCookie("token").value !== "undefined") {
|
||||
headers["Authorization"] = `Token ${useCookie("token").value}`;
|
||||
}
|
||||
|
||||
const { data, error } = await useFetch<MovieList[]>(
|
||||
`${config.public.apiURL}/lists`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-type": "application/json",
|
||||
Authorization: `Token ${useCookie("token").value}`,
|
||||
},
|
||||
headers: headers,
|
||||
},
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue