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

const store = (set) => ({
  clickedPointConfig: null,

  setClickedPointConfig: (id, shouldSelect = true) => {
    set((state) => {
      if (id === null) {
        state.clickedPointConfig = null;
        return state;
      }
      state.clickedPointConfig = {
        id,
        shouldSelect,
      };
    });
  },
});

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