improved Popup handleing

This commit is contained in:
PxlLoewe
2025-04-09 09:33:13 -07:00
parent dc55b46385
commit 9e430eeeec
6 changed files with 93 additions and 57 deletions

View File

@@ -2,8 +2,7 @@ import { popup } from "leaflet";
import { create } from "zustand";
interface MapStore {
popup: {
isOpen: boolean;
contextMenu: {
lat: number;
lng: number;
} | null;
@@ -11,6 +10,8 @@ interface MapStore {
center: L.LatLngExpression;
zoom: number;
};
openMissionMarker: string[];
setOpenMissionMarker: (mission: { open: string[]; close: string[] }) => void;
searchElements: {
id: number;
nodes: {
@@ -29,30 +30,38 @@ interface MapStore {
type: string;
}[];
setSearchElements: (elements: MapStore["searchElements"]) => void;
setPopup: (popup: MapStore["popup"]) => void;
searchPopup?: {
isOpen: boolean;
setContextMenu: (popup: MapStore["contextMenu"]) => void;
searchPopup: {
lat: number;
lng: number;
elementId: number;
};
} | null;
setSearchPopup: (popup: MapStore["searchPopup"]) => void;
}
export const useMapStore = create<MapStore>((set, get) => ({
openMissionMarker: [],
setOpenMissionMarker: ({ open, close }) => {
set((state) => ({
openMissionMarker: [...state.openMissionMarker, ...open].filter(
(id) => !close.includes(id),
),
}));
},
map: {
center: [51.5, 10.5],
zoom: 6,
},
searchPopup: null,
searchElements: [],
setSearchPopup: (popup) =>
set((state) => ({
searchPopup: popup,
})),
popup: null,
setPopup: (popup) =>
contextMenu: null,
setContextMenu: (contextMenu) =>
set((state) => ({
popup: popup,
contextMenu,
})),
setSearchElements: (elements) =>
set((state) => ({