refactor: remove some duplicated code

This commit is contained in:
2023-08-01 17:50:00 +02:00
parent 01697a6686
commit c5cf629482
30 changed files with 377 additions and 321 deletions

View File

@ -1,5 +1,5 @@
import { Menu } from "@islands/KMenu/types.ts";
import { Movie } from "@lib/movies.ts";
import { Movie } from "@lib/resource/movies.ts";
import { TMDBMovie } from "@lib/types.ts";
export const menus: Record<string, Menu> = {
@ -41,11 +41,10 @@ export const menus: Record<string, Menu> = {
title: `${m.title} released ${m.release_date}`,
cb: async () => {
state.activeState.value = "loading";
const res = await fetch(`/api/movies/${movie.name}/`, {
await fetch(`/api/movies/${movie.name}/`, {
method: "POST",
body: JSON.stringify({ tmdbId: m.id }),
});
const j = await res.json();
state.visible.value = false;
state.activeState.value = "normal";
window.location.reload();