hooks auslagern von MapComponent, useInitializeMap.js und useLoadUserRights.js
This commit is contained in:
@@ -78,9 +78,11 @@ import ShowAddStationPopup from "../AddPOIModal.js";
|
||||
import { useInitGisStationsStatic } from "../mainComponent/hooks/webServices/useInitGisStationsStatic";
|
||||
import { closeAddPoiModal } from "../../redux/slices/addPoiOnPolylineSlice.js";
|
||||
import AddPOIOnPolyline from "../AddPOIOnPolyline";
|
||||
|
||||
import { enablePolylineEvents, disablePolylineEvents } from "../../utils/polylines/eventHandlers";
|
||||
import { updateCountdown, closePolylineContextMenu, forceCloseContextMenu } from "../../redux/slices/polylineContextMenuSlice";
|
||||
//-------------------MapComponent.js hooks--------------------
|
||||
import useInitializeMap from "./hooks/useInitializeMap";
|
||||
import useLoadUserRights from "./hooks/useLoadUserRights";
|
||||
|
||||
const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
const dispatch = useDispatch();
|
||||
@@ -251,18 +253,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
isRightsLoaded, // Überprüfung, ob die Rechte geladen sind
|
||||
]); */
|
||||
|
||||
useEffect(() => {
|
||||
const fetchAndSetUserRights = async () => {
|
||||
const rights = await fetchUserRights();
|
||||
setUserRights(rights);
|
||||
setIsRightsLoaded(true);
|
||||
|
||||
// Sicherstellen, dass `rights` ein Array ist, bevor `.includes()` aufgerufen wird
|
||||
setHasRights(localStorage.getItem("editMode") && Array.isArray(rights) && rights.includes(56));
|
||||
};
|
||||
|
||||
fetchAndSetUserRights();
|
||||
}, []);
|
||||
useLoadUserRights(setUserRights, setIsRightsLoaded, setHasRights);
|
||||
|
||||
useGmaMarkersLayer(
|
||||
map,
|
||||
@@ -722,11 +713,9 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
fetchPriorityConfig();
|
||||
}, []);
|
||||
//--------------------------------------------
|
||||
useEffect(() => {
|
||||
if (mapRef.current && !map) {
|
||||
initializeMap(mapRef, setMap, setOms, setMenuItemAdded, addItemsToMapContextMenu, hasRights, setPolylineEventsDisabled);
|
||||
}
|
||||
}, [mapRef, map, hasRights, setPolylineEventsDisabled]);
|
||||
useInitializeMap(map, mapRef, setMap, setOms, setMenuItemAdded, addItemsToMapContextMenu, hasRights, setPolylineEventsDisabled);
|
||||
|
||||
//--------------------------------------------
|
||||
|
||||
useEffect(() => {
|
||||
if (map) {
|
||||
@@ -737,6 +726,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
}
|
||||
}
|
||||
}, [map, polylineEventsDisabled]);
|
||||
//--------------------------------------------
|
||||
useEffect(() => {
|
||||
if (map) {
|
||||
console.log("6- Karteninstanz (map) wurde jetzt erfolgreich initialisiert");
|
||||
|
||||
Reference in New Issue
Block a user