feat: integrate database operations for movie management in global store and UI components; enhance MovieCast with dynamic cast display and button for full cast visibility

This commit is contained in:
Norbert Maciaszek
2025-08-18 00:24:08 +02:00
parent 5a6ee42e28
commit 7a7bc2575b
5 changed files with 40 additions and 20 deletions

View File

@@ -1,6 +1,5 @@
"use client";
import { FC } from "react";
import { addMovie, deleteMovie, updateMovie } from "@/lib/db";
import { useGlobalStore } from "@/app/store/globalStore";
import { Movie } from "@/types/global";
import {
@@ -37,23 +36,19 @@ export const MovieCard: FC<Props> = ({
const buttonClass =
"p-4 text-sm transition-colors cursor-pointer text-center group/toggle";
const handleAdd = async () => {
await addMovie(movie);
const handleAdd = () => {
addMovieToStore(movie);
};
const handleRemove = async () => {
await deleteMovie(id);
const handleRemove = () => {
deleteMovieFromStore(id);
};
const handleSeen = async () => {
await updateMovie(id, { seen: !movie.seen });
const handleSeen = () => {
updateMovieInStore(id, { seen: !movie.seen });
};
const handleFavorite = async () => {
await updateMovie(id, { favorite: !movie.favorite });
const handleFavorite = () => {
updateMovieInStore(id, { favorite: !movie.favorite });
};