From 28dd0006bc485aac73e1f1ee5567b45aa3834de1 Mon Sep 17 00:00:00 2001 From: ISA Date: Fri, 23 May 2025 13:49:57 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20POI-Bearbeiten-Rechte=20gepr=C3=BCft,=20?= =?UTF-8?q?Kontextmen=C3=BC=20&=20Modal=20korrigiert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Rechteprüfung auf .some(r => r.IdRight === 56) umgestellt - Bug in PoiUpdateModal behoben (falscher fetchLocationDevices Import) - Modal öffnet sich nur mit gültigem Bearbeitungsrecht - Version auf 1.1.159 erhöht --- CHANGELOG.md | 30 +++++++++++++++++++ components/pois/PoiUpdateModal.js | 4 +-- config/appVersion.js | 2 +- services/webservice/fetchUserRightsService.js | 4 ++- utils/poiUtils.js | 2 +- utils/setupPOIs.js | 3 +- 6 files changed, 39 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b01dbf23..8bc63ec6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,36 @@ Alle bedeutenden Änderungen an diesem Projekt werden in dieser Datei dokumentie --- +## [1.1.159] – 2025-05-23 + +### 🐞 Fixed + +- Fehler behoben: `userRights.includes(56)` schlug fehl, da Rechteobjekte `{ IdRight }` enthalten – ersetzt durch `.some(r => r.IdRight === 56)` +- Kontextmenü „POI bearbeiten“ wird jetzt korrekt angezeigt +- Modal öffnet sich nur noch bei gültiger Berechtigung (56) + +### ✅ Clean + +- Rechteprüfung in `setupPOIs.js` und `poiUtils.js` vereinheitlicht +- `handleEditPoi(...)` überprüft jetzt korrekt mit `.some(...)` + +### 💥 Bugfix + +- Fehler `TypeError: fetchLocationDevicesFromDB is not a function` in `PoiUpdateModal.js` behoben + - Ursache: falscher Import aus Slice statt Thunk + - Lösung: Import auf `fetchLocationDevicesThunk` geändert + +### 🧠 Architektur + +- POI-Rechte über Webservice vollständig in Redux geladen +- `PoiUpdateModal.js` verwendet Redux Thunk zur Initialisierung von Location Devices + +### 🔧 Version + +- 📦 Version erhöht auf **1.1.159** + +--- + ## [1.1.158] – 2025-05-23 ### ✨ Feature diff --git a/components/pois/PoiUpdateModal.js b/components/pois/PoiUpdateModal.js index 63827809e..490718af2 100644 --- a/components/pois/PoiUpdateModal.js +++ b/components/pois/PoiUpdateModal.js @@ -1,7 +1,7 @@ // /components/pois/PoiUpdateModal.js import React, { useState, useEffect } from "react"; import Select from "react-select"; // Importiere react-select -import { fetchLocationDevicesFromDB } from "../../redux/slices/database/locationDevicesFromDBSlice"; +import { fetchLocationDevicesThunk } from "../../redux/thunks/database/fetchLocationDevicesThunk"; import { useSelector, useDispatch } from "react-redux"; import { selectMapLayersState } from "../../redux/slices/mapLayersSlice"; @@ -40,7 +40,7 @@ const PoiUpdateModal = ({ onClose, poiData, onSubmit }) => { const devices = useSelector((state) => state.locationDevicesFromDB.devices); useEffect(() => { - dispatch(fetchLocationDevicesFromDB()); + dispatch(fetchLocationDevicesThunk()); }, [dispatch]); useEffect(() => { diff --git a/config/appVersion.js b/config/appVersion.js index 706400ebc..2cf479c8d 100644 --- a/config/appVersion.js +++ b/config/appVersion.js @@ -1,2 +1,2 @@ // /config/appVersion -export const APP_VERSION = "1.1.158"; +export const APP_VERSION = "1.1.160"; diff --git a/services/webservice/fetchUserRightsService.js b/services/webservice/fetchUserRightsService.js index 690a68d22..e250df824 100644 --- a/services/webservice/fetchUserRightsService.js +++ b/services/webservice/fetchUserRightsService.js @@ -7,7 +7,8 @@ export const fetchUserRightsService = async () => { const idMap = params.get("m"); const idUser = params.get("u"); - const url = `${apiBaseUrl}/GetUserRights?idMap=${idMap}&idUser=${idUser}`; + const url = `${apiBaseUrl}/GisSystemStatic?idMap=${idMap}&idUser=${idUser}`; + console.log("🔍 Rechte-Fetch URL:", url); const response = await fetch(url, { method: "GET", @@ -21,5 +22,6 @@ export const fetchUserRightsService = async () => { } const json = await response.json(); + console.log("👤 Rechte-Response JSON:", json); return json.Rights || []; }; diff --git a/utils/poiUtils.js b/utils/poiUtils.js index ddeb32e55..4c65dfdb1 100644 --- a/utils/poiUtils.js +++ b/utils/poiUtils.js @@ -91,7 +91,7 @@ export const handleEditPoi = ( console.log("User Rights includes 56:", userRights.includes(56)); // Prüfung, ob der Benutzer die notwendigen Rechte hat - if (!userRights.includes(56)) { + if (!userRights.some((r) => r.IdRight === 56)) { toast.error("Benutzer hat keine Berechtigung zum Bearbeiten.", { position: "top-center", autoClose: 5000, diff --git a/utils/setupPOIs.js b/utils/setupPOIs.js index 800bb8ddb..1c3f79f0b 100644 --- a/utils/setupPOIs.js +++ b/utils/setupPOIs.js @@ -43,7 +43,8 @@ export const setupPOIs = async ( try { const { latitude, longitude } = parsePoint(location.position); const poiTypName = poiTypMap.get(location.idPoiTyp) || "Unbekannt"; - const canDrag = userRights ? userRights.includes(56) : false; + const canDrag = userRights ? userRights.some((r) => r.IdRight === 56) : false; + const matchingIcon = poiData.find((poi) => poi.idPoi === location.idPoi); const iconUrl = matchingIcon ? `/img/icons/pois/${matchingIcon.path}` : "/img/icons/pois/default-icon.png";