You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
752 B
31 lines
752 B
import { create } from "zustand";
|
|
import { immer } from "zustand/middleware/immer";
|
|
import { LAYER_IDS } from "../Map/Layers/constants";
|
|
|
|
const INITIAL_STATE = {
|
|
[LAYER_IDS.initial]: true,
|
|
[LAYER_IDS.approve]: false,
|
|
[LAYER_IDS.working]: false,
|
|
};
|
|
|
|
const store = (set) => ({
|
|
isVisible: INITIAL_STATE,
|
|
|
|
toggleVisibility: (layerId) =>
|
|
set((state) => {
|
|
state.isVisible[layerId] = !state.isVisible[layerId];
|
|
}),
|
|
|
|
setLayersVisibility: (config) =>
|
|
set((state) => {
|
|
config.visible.forEach((layerId) => {
|
|
state.isVisible[layerId] = true;
|
|
});
|
|
config.invisible.forEach((layerId) => {
|
|
state.isVisible[layerId] = false;
|
|
});
|
|
}),
|
|
});
|
|
|
|
export const useLayersVisibility = create(immer(store));
|