diff --git a/CHANGELOG.md b/CHANGELOG.md index 52d85eafe..248242874 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,26 @@ Alle bedeutenden Änderungen an diesem Projekt werden in dieser Datei dokumentie --- +## [1.1.147] - 2025-05-22 + +### Hinzugefügt + +- Redux-Slice `gisUserRightsFromWebservice` eingeführt zur Ablösung von `useLoadUserRights.js` +- Zustand `userRights` jetzt vollständig über Redux gesteuert + +### Geändert + +- `MapComponent.js` angepasst: `useLoadUserRights.js` entfernt, stattdessen Thunk + Selector verwendet +- `fetchUserRightsThunk` direkt in `MapComponent.js` integriert + +### Architektur + +- Redux-Toolkit wird jetzt systematisch für Webservice-Daten verwendet +- Bessere Trennung zwischen Service, Thunk und Slice +- Lesbarkeit und Wartbarkeit deutlich verbessert + +--- + ## [1.1.144] – 2025-05-22 ### Fixed diff --git a/components/mainComponent/MapComponent.js b/components/mainComponent/MapComponent.js index d7488af98..f600977c6 100644 --- a/components/mainComponent/MapComponent.js +++ b/components/mainComponent/MapComponent.js @@ -46,7 +46,7 @@ import { enablePolylineEvents, disablePolylineEvents } from "../../utils/polylin import { updateCountdown, closePolylineContextMenu } from "../../redux/slices/polylineContextMenuSlice"; //-------------------MapComponent.js hooks-------------------- import useInitializeMap from "./hooks/useInitializeMap"; -import useLoadUserRights from "./hooks/useLoadUserRights"; + import useFetchPoiData from "./hooks/useFetchPoiData.js"; import useRestoreMapSettings from "./hooks/useRestoreMapSettings"; import { setSelectedPoi } from "../../redux/slices/selectedPoiSlice"; @@ -67,6 +67,7 @@ import { fetchUserRightsThunk } from "../../redux/thunks/webservice/fetchUserRig import { selectGisLines } from "../../redux/slices/database/gisLinesSlice"; import { selectGisLinesStatus } from "../../redux/slices/webservice/gisLinesStatusSlice"; import { selectGisLinesStatusFromWebservice } from "../../redux/slices/webservice/gisLinesStatusSlice"; +import { selectGisUserRightsFromWebservice } from "../../redux/slices/webservice/userRightsSlice"; const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { //------------------------------- @@ -106,10 +107,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { const [isPopupOpen, setIsPopupOpen] = useState(false); const closePopup = () => setIsPopupOpen(false); const [currentCoordinates, setCurrentCoordinates] = useState(""); - const [isRightsLoaded, setIsRightsLoaded] = useState(false); - const [hasRights, setHasRights] = useState(false); const [AddPoiModalWindowState, setAddPoiModalWindowState] = useState(false); - const [userRights, setUserRights] = useState(null); const [showPoiUpdateModal, setShowPoiUpdateModal] = useState(false); const [currentPoiData, setCurrentPoiData] = useState(null); const [showVersionInfoModal, setShowVersionInfoModal] = useState(false); @@ -120,7 +118,11 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { const [map, setMap] = useState(null); // Zustand der Karteninstanz const [oms, setOms] = useState(null); // State für OMS-Instanz const [GisStationsMeasurements, setGisStationsMeasurements] = useState([]); // Zustand für Messdaten - + //-----userRights---------------- + const isRightsLoaded = useSelector((state) => state.gisUserRightsFromWebservice.status === "succeeded"); + const userRights = useSelector(selectGisUserRightsFromWebservice); + const hasRights = userRights.includes(56); + //----------------------------- const openPopupWithCoordinates = (e) => { const coordinates = `${e.latlng.lat.toFixed(5)}, ${e.latlng.lng.toFixed(5)}`; setCurrentCoordinates(coordinates); @@ -555,7 +557,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { //--------------------------------- //--------------hokks------------------------------------------- - useLoadUserRights(setUserRights, setIsRightsLoaded, setHasRights); + useGmaMarkersLayer( map, gmaMarkers, @@ -768,6 +770,10 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { ); } }, [map, menuItemAdded]); + //-------------------------------------------- + useEffect(() => { + dispatch(fetchUserRightsThunk()); + }, [dispatch]); //-------------------------------------------- // Beim ersten Client-Render den Wert aus localStorage laden diff --git a/components/mainComponent/hooks/useLoadUserRights.js b/components/mainComponent/hooks/useLoadUserRights.js deleted file mode 100644 index 9ae56b705..000000000 --- a/components/mainComponent/hooks/useLoadUserRights.js +++ /dev/null @@ -1,20 +0,0 @@ -// /components/mainComponent/hooks/useLoadUserRights.js -import { useEffect } from "react"; -import { fetchUserRightsService } from "../../../services/webservice/fetchUserRightsService"; - -const useLoadUserRights = (setUserRights, setIsRightsLoaded, setHasRights) => { - useEffect(() => { - const fetchAndSetUserRights = async () => { - const rights = await fetchUserRightsService(); - 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(); - }, []); -}; - -export default useLoadUserRights; diff --git a/config/appVersion.js b/config/appVersion.js index 71996a1b5..ea411a6d6 100644 --- a/config/appVersion.js +++ b/config/appVersion.js @@ -1,2 +1,2 @@ // /config/appVersion -export const APP_VERSION = "1.1.147"; +export const APP_VERSION = "1.1.148";