import { create } from 'zustand';
import { persist } from 'zustand/middleware';

interface IPopupStore {
  isShowPopup: boolean | undefined;
  setIsShowPopup: (isShowPopup: boolean) => void;
  isShowCookiesPopup: boolean | undefined;
  setIsShowCookiesPopup: (isShowCookiesPopup: boolean) => void;
}

export const usePopupStore = create<IPopupStore>()(
  persist(
    set => ({
      isShowPopup: undefined,
      setIsShowPopup: (isShowPopup: boolean) => set({ isShowPopup }),
      isShowCookiesPopup: undefined,
      setIsShowCookiesPopup: (isShowCookiesPopup: boolean) =>
        set({ isShowCookiesPopup }),
    }),
    {
      name: 'popup',
    },
  ),
);
