import { CategoryResult } from '@/shared/config/api/category/type';
import { create } from 'zustand';

type Category = {
  active: CategoryResult | null;
  openToolbar: boolean;
};

type Actions = {
  setActive: (active: CategoryResult | null) => void;
  setOpenToolbar: (openToolbar: boolean) => void;
  setCloseToolbar: (openToolbar: boolean) => void;
};

const useCategoryActive = create<Category & Actions>((set) => ({
  active: null,
  openToolbar: false,
  setActive: (active: CategoryResult | null) => set(() => ({ active })),
  setOpenToolbar: () => set(() => ({ openToolbar: true })),
  setCloseToolbar: () => set(() => ({ openToolbar: false })),
}));

export default useCategoryActive;
