import { create } from "zustand";
import { immer } from "zustand/middleware/immer";

const INITIAL_STATE = {
  isOpened: false,
  fullScreen: false,
};

const store = (set) => ({
  tableState: INITIAL_STATE,

  toggleOpened: (value) => {
    set((state) => {
      state.tableState.isOpened = value[0] === "opened";
    });
  },

  toggleFullScreen: () => {
    set((state) => {
      state.tableState.fullScreen = !state.tableState.fullScreen;
    });
  },

  openTable: () => {
    set((state) => {
      state.tableState.isOpened = true;
    });
  },
});

export const useTable = create(immer(store));
