parent
5c7dbc59f7
commit
5255442cde
@ -0,0 +1,34 @@
|
|||||||
|
import { Title } from "../../components/Title";
|
||||||
|
import { Checkbox } from "antd";
|
||||||
|
import {
|
||||||
|
getGridVisibility,
|
||||||
|
getPointsVisibility,
|
||||||
|
useLayersStore,
|
||||||
|
} from "../../stores/useLayersStore";
|
||||||
|
|
||||||
|
export const LayersVisibility = () => {
|
||||||
|
const { toggleVisibility } = useLayersStore();
|
||||||
|
const isPointsVisible = useLayersStore(getPointsVisibility);
|
||||||
|
const isGridVisible = useLayersStore(getGridVisibility);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Title text={"Слои"} className={"mb-1"} />
|
||||||
|
<div className={"space-y-1"}>
|
||||||
|
<Checkbox
|
||||||
|
onChange={() => toggleVisibility("points")}
|
||||||
|
checked={isPointsVisible}
|
||||||
|
>
|
||||||
|
Точки постаматов
|
||||||
|
</Checkbox>
|
||||||
|
<Checkbox
|
||||||
|
className={"!ml-0"}
|
||||||
|
onChange={() => toggleVisibility("grid")}
|
||||||
|
checked={isGridVisible}
|
||||||
|
>
|
||||||
|
Тепловая карта
|
||||||
|
</Checkbox>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
import create from "zustand";
|
||||||
|
import { immer } from "zustand/middleware/immer";
|
||||||
|
|
||||||
|
const INITIAL_STATE = {
|
||||||
|
points: {
|
||||||
|
visible: true,
|
||||||
|
filter: {},
|
||||||
|
},
|
||||||
|
grid: {
|
||||||
|
visible: true,
|
||||||
|
filter: {},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const store = (set) => ({
|
||||||
|
layers: INITIAL_STATE,
|
||||||
|
toggleVisibility: (layerId) =>
|
||||||
|
set((state) => {
|
||||||
|
state.layers[layerId].visible = !state.layers[layerId].visible;
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const useLayersStore = create(immer(store));
|
||||||
|
|
||||||
|
export const getLayerVisibility = (layerId) => (state) =>
|
||||||
|
state.layers[layerId].visible;
|
||||||
|
|
||||||
|
export const getPointsVisibility = getLayerVisibility("points");
|
||||||
|
export const getGridVisibility = getLayerVisibility("grid");
|
||||||
Loading…
Reference in new issue