import { create } from "./Create";

type State = {
  folder: any;
  currentFolderId: string;
};

type Actions = {
  setFolder: (folder: any) => void;
  setCurrentFolderId: (folderId: string) => void;
  reset: () => void;
};

// define the initial state
const initialState: State = {
  folder: {},
  currentFolderId: "",
};
// create store
const useCurrentFolder = create<State & Actions>()((set, get) => ({
  ...initialState,

  setFolder: (_folder: any) => {
    set({ folder: _folder });
  },

  setCurrentFolderId: (folderId: string) => {
    set({ currentFolderId: folderId });
  },

  reset: () => {
    set(initialState);
  },
}));

export { useCurrentFolder };
