feat: Fetch-Logik für Benutzerrechte in useFetchUserRights Hook ausgelagert
- Fetch-Logik für Benutzerrechte aus MapComponent.js in einen separaten Hook ausgelagert. - Neuer Hook: useFetchUserRights im hooks-Verzeichnis hinzugefügt. - Verbesserung der Modularität und Wiederverwendbarkeit.
This commit is contained in:
@@ -48,6 +48,7 @@ import { useFetchLineStatusData } from "../hooks/useFetchLineStatusData";
|
||||
import { useFetchPriorityConfig } from "../hooks/useFetchPriorityConfig";
|
||||
import { useUpdateGmaData } from "../hooks/useUpdateGmaData";
|
||||
import { useDynamicMarkerLayers } from "../hooks/useDynamicMarkerLayers";
|
||||
import { useFetchUserRights } from "../hooks/useFetchUserRights";
|
||||
//--------------------------------------------
|
||||
import { currentPoiState } from "../redux/slices/currentPoiSlice.js";
|
||||
import { selectGisStationsStaticDistrict, setGisStationsStaticDistrict } from "../redux/slices/gisStationsStaticDistrictSlice";
|
||||
@@ -205,18 +206,11 @@ 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);
|
||||
//---------------------------------------------------------------
|
||||
// Benutzerrechte abrufen und setzen
|
||||
useFetchUserRights(setUserRights, setIsRightsLoaded, setHasRights);
|
||||
|
||||
// Sicherstellen, dass `rights` ein Array ist, bevor `.includes()` aufgerufen wird
|
||||
setHasRights(localStorage.getItem("editMode") && Array.isArray(rights) && rights.includes(56));
|
||||
};
|
||||
|
||||
fetchAndSetUserRights();
|
||||
}, []);
|
||||
//---------------------------------------------------------------
|
||||
|
||||
useGmaMarkersLayer(
|
||||
map,
|
||||
@@ -451,7 +445,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
sonstigeMarkers,
|
||||
tkComponentsMarkers,
|
||||
ulafMarkers,
|
||||
mapLayersVisibility, // Neu: Abhängigkeit für Sichtbarkeitsstatus
|
||||
mapLayersVisibility,
|
||||
]);
|
||||
|
||||
//--------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user