movie-night-web/src/pages/lists/index.vue

45 lines
1.1 KiB
Vue
Raw Normal View History

2025-03-30 20:51:11 -05:00
<template>
<div class="p-5 sm:p-0">
<ul class="grid grid-cols-2 gap-3 mt-5">
<li v-for="list in lists" class="movie-card neon-border p-5 rounded">
<div class="grid grid-rows-2 gap-3">
<NuxtLink :to="`/lists/${list.id}`" class="underline">
<h2 class="text-lg">{{ list.name }}</h2>
</NuxtLink>
<span>Movies: {{ list.movie_count }}</span>
</div>
</li>
</ul>
</div>
</template>
<script lang="ts" setup>
import type { MovieList } from "~/types/movielist";
const lists = defineModel<MovieList[]>("movie_list", { default: [] });
const updateLists = async function () {
let config = useRuntimeConfig();
const { data, status, error } = await useFetch<MovieList[]>(
`${config.public.apiURL}/lists`,
{
method: "GET",
headers: { "Content-type": "application/json" },
2025-03-30 20:51:11 -05:00
},
);
if (error) {
if (error.value?.statusCode === 401) {
console.log("unauthorized");
}
} else {
lists.value = data.value || [];
2025-03-30 20:51:11 -05:00
}
};
2025-03-30 20:51:11 -05:00
onMounted(() => {
updateLists();
});
</script>
2025-03-30 20:51:11 -05:00
<style scoped></style>