import { create } from 'zustand'
import type { TmdbMovie, TmdbTvShow } from '../api/tmdb'

interface State {
  open: boolean
  tmdbId: number | null
  kind: 'movie' | 'tv'
  tmdbData: TmdbMovie | TmdbTvShow | null
  show: (args: { tmdbId: number; kind: 'movie' | 'tv'; tmdbData: TmdbMovie | TmdbTvShow | null }) => void
  close: () => void
}

export const useRequestModal = create<State>(set => ({
  open: false,
  tmdbId: null,
  kind: 'movie',
  tmdbData: null,
  show: ({ tmdbId, kind, tmdbData }) => set({ open: true, tmdbId, kind, tmdbData }),
  close: () => set({ open: false }),
}))
