import create from 'zustand'
import { defaultTheme } from '../assets/theme'

export const useSeriesStore = create((set, get) => ({
  series: {},
  episodes: [],
  setSeries: series => set({ series }),
  setEpisodes: () => {
    if (get().series) {
      set({
        episodes: get().series.map(series => series.episodes)
      })
    } else set({})
  }
}))

export const [useTheme] = create(set => ({
  theme: defaultTheme,
  setTheme: (theme) => set({ theme }),
  setDefaultTheme: () => set({ theme: defaultTheme })
}))

export const [useUiStore] = create((set, get) => ({
  mobileMenuOpen: false,
  toggleMobileMenu: () => set({ mobileMenuOpen: !get().mobileMenuOpen }),
}))