refactor(hooks): useMapComponentState vollständig auf Redux umgestellt
- fetch-Aufrufe entfernt und durch Redux-Selektoren ersetzt - poiTypData über poiTypSlice + fetchPoiTypThunk geladen - locationDeviceData über gisStationsStaticDistrictThunk - priorityConfig über Redux mit fetchPriorityConfigThunk integriert - poiLayerVisible direkt aus Redux-State gelesen - Version auf 1.1.173 erhöht
This commit is contained in:
35
CHANGELOG.md
35
CHANGELOG.md
@@ -4,6 +4,41 @@ Alle bedeutenden Änderungen an diesem Projekt werden in dieser Datei dokumentie
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
[1.1.173] – 2025-05-26
|
||||||
|
♻️ Refactor
|
||||||
|
useMapComponentState.js vollständig auf Redux umgestellt:
|
||||||
|
|
||||||
|
Entfernt: lokale fetch(...)-Aufrufe
|
||||||
|
|
||||||
|
Redux-Integration für:
|
||||||
|
|
||||||
|
poiTypData → über poiTypSlice + fetchPoiTypThunk
|
||||||
|
|
||||||
|
locationDeviceData → über gisStationsStaticDistrictSlice + fetchGisStationsStaticDistrictThunk
|
||||||
|
|
||||||
|
priorityConfig → über priorityConfigSlice + fetchPriorityConfigThunk
|
||||||
|
|
||||||
|
poiLayerVisible → direkter Zugriff über Redux-Zustand
|
||||||
|
|
||||||
|
🧠 Architektur
|
||||||
|
useMapComponentState.js ist jetzt rein selektorbasiert
|
||||||
|
|
||||||
|
Standardstruktur Service → Thunk → Slice vollständig eingehalten
|
||||||
|
|
||||||
|
Komponente reagiert nur noch auf Redux-Status (z. B. poiTypStatus === "succeeded")
|
||||||
|
|
||||||
|
✅ Cleanup
|
||||||
|
useState() für priorityConfig und locationDeviceData entfernt
|
||||||
|
|
||||||
|
deviceName wird direkt aus Redux-Daten abgeleitet
|
||||||
|
|
||||||
|
Selektor für poiLayerVisible wird direkt inline verwendet
|
||||||
|
|
||||||
|
🔧 Version
|
||||||
|
📦 Version erhöht auf 1.1.173
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## [1.1.166] – 2025-05-25
|
## [1.1.166] – 2025-05-25
|
||||||
|
|
||||||
### 🐞 Fixed
|
### 🐞 Fixed
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ import { setCurrentPoi } from "../../redux/slices/database/pois/currentPoiSlice.
|
|||||||
import { selectGisLines } from "../../redux/slices/database/polylines/gisLinesSlice";
|
import { selectGisLines } from "../../redux/slices/database/polylines/gisLinesSlice";
|
||||||
import { selectGisLinesStatus } from "../../redux/slices/webservice/gisLinesStatusSlice";
|
import { selectGisLinesStatus } from "../../redux/slices/webservice/gisLinesStatusSlice";
|
||||||
import { selectPoiTypData, selectPoiTypStatus } from "../../redux/slices/database/pois/poiTypSlice";
|
import { selectPoiTypData, selectPoiTypStatus } from "../../redux/slices/database/pois/poiTypSlice";
|
||||||
import { selectPriorityConfig } from "../../redux/slices/database/priorityConfigSlice";
|
import { selectPriorityConfig } from "../../redux/slices/database/priorityConfigSlice.js";
|
||||||
import { selectPoiIconsData, selectPoiIconsStatus } from "../../redux/slices/database/pois/poiIconsDataSlice";
|
import { selectPoiIconsData, selectPoiIconsStatus } from "../../redux/slices/database/pois/poiIconsDataSlice";
|
||||||
import { selectGisLinesStatusFromWebservice } from "../../redux/slices/webservice/gisLinesStatusSlice";
|
import { selectGisLinesStatusFromWebservice } from "../../redux/slices/webservice/gisLinesStatusSlice";
|
||||||
import { selectGisUserRightsFromWebservice } from "../../redux/slices/webservice/userRightsSlice";
|
import { selectGisUserRightsFromWebservice } from "../../redux/slices/webservice/userRightsSlice";
|
||||||
@@ -62,7 +62,7 @@ import { fetchGisSystemStaticThunk } from "../../redux/thunks/webservice/fetchGi
|
|||||||
import { fetchGisStationsStaticDistrictThunk } from "../../redux/thunks/webservice/fetchGisStationsStaticDistrictThunk";
|
import { fetchGisStationsStaticDistrictThunk } from "../../redux/thunks/webservice/fetchGisStationsStaticDistrictThunk";
|
||||||
import { fetchGisStationsStatusDistrictThunk } from "../../redux/thunks/webservice/fetchGisStationsStatusDistrictThunk";
|
import { fetchGisStationsStatusDistrictThunk } from "../../redux/thunks/webservice/fetchGisStationsStatusDistrictThunk";
|
||||||
import { fetchLocationDevicesThunk } from "../../redux/thunks/database/fetchLocationDevicesThunk";
|
import { fetchLocationDevicesThunk } from "../../redux/thunks/database/fetchLocationDevicesThunk";
|
||||||
import { fetchPriorityConfigThunk } from "../../redux/thunks/database/fetchPriorityConfigThunk";
|
import { fetchPriorityConfigThunk } from "../../redux/thunks/database/fetchPriorityConfigThunk.js";
|
||||||
import { fetchGisLinesThunk } from "../../redux/thunks/database/polylines/fetchGisLinesThunk.js";
|
import { fetchGisLinesThunk } from "../../redux/thunks/database/polylines/fetchGisLinesThunk.js";
|
||||||
import { fetchGisLinesStatusThunk } from "../../redux/thunks/webservice/fetchGisLinesStatusThunk";
|
import { fetchGisLinesStatusThunk } from "../../redux/thunks/webservice/fetchGisLinesStatusThunk";
|
||||||
import { fetchUserRightsThunk } from "../../redux/thunks/webservice/fetchUserRightsThunk";
|
import { fetchUserRightsThunk } from "../../redux/thunks/webservice/fetchUserRightsThunk";
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
// /config/appVersion
|
// /config/appVersion
|
||||||
export const APP_VERSION = "1.1.173";
|
export const APP_VERSION = "1.1.174";
|
||||||
|
|||||||
@@ -1,84 +1,65 @@
|
|||||||
// /hooks/useMapComponentState.js
|
// /hooks/useMapComponentState.js
|
||||||
|
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
|
|
||||||
|
// Redux: POI-Typen
|
||||||
import { fetchPoiTypThunk } from "../redux/thunks/database/pois/fetchPoiTypThunk";
|
import { fetchPoiTypThunk } from "../redux/thunks/database/pois/fetchPoiTypThunk";
|
||||||
import { selectPoiTypData, selectPoiTypStatus } from "../redux/slices/database/pois/poiTypSlice";
|
import { selectPoiTypData, selectPoiTypStatus } from "../redux/slices/database/pois/poiTypSlice";
|
||||||
import { selectPoiLayerVisible } from "../redux/slices/database/pois/poiLayerVisibleSlice";
|
|
||||||
|
// Redux: GIS Geräte
|
||||||
|
import { fetchGisStationsStaticDistrictThunk } from "../redux/thunks/webservice/fetchGisStationsStaticDistrictThunk";
|
||||||
|
import { selectGisStationsStaticDistrict } from "../redux/slices/webservice/gisStationsStaticDistrictSlice";
|
||||||
|
|
||||||
|
// Redux: priorityConfig
|
||||||
|
import { fetchPriorityConfigThunk } from "../redux/thunks/database/fetchPriorityConfigThunk";
|
||||||
|
import { selectPriorityConfig } from "../redux/slices/database/priorityConfigSlice";
|
||||||
|
|
||||||
export const useMapComponentState = () => {
|
export const useMapComponentState = () => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
|
// Redux: Sichtbarkeit des POI-Layers
|
||||||
|
const poiLayerVisible = useSelector((state) => state.poiLayerVisible.visible);
|
||||||
|
|
||||||
// Redux: POI-Typen
|
// Redux: POI-Typen
|
||||||
const poiTypData = useSelector(selectPoiTypData);
|
const poiTypData = useSelector(selectPoiTypData);
|
||||||
const poiTypStatus = useSelector(selectPoiTypStatus);
|
const poiTypStatus = useSelector(selectPoiTypStatus);
|
||||||
|
|
||||||
// Redux: Sichtbarkeit des POI-Layers
|
// Redux: Geräte
|
||||||
const poiLayerVisible = useSelector((state) => state.poiLayerVisible.visible);
|
const locationDeviceData = useSelector(selectGisStationsStaticDistrict);
|
||||||
|
const deviceName = locationDeviceData?.Points?.[0]?.LD_Name || "";
|
||||||
|
|
||||||
// Lokaler State: Geräte und Kontextmenü
|
// Redux: Prioritätskonfiguration
|
||||||
const [deviceName, setDeviceName] = useState("");
|
const priorityConfig = useSelector(selectPriorityConfig);
|
||||||
const [locationDeviceData, setLocationDeviceData] = useState([]);
|
|
||||||
const [priorityConfig, setPriorityConfig] = useState([]); // TODO: Redux
|
// UI-interner Zustand
|
||||||
const [menuItemAdded, setMenuItemAdded] = useState(false);
|
const [menuItemAdded, setMenuItemAdded] = useState(false);
|
||||||
|
|
||||||
// Optional: Nur im Mock-Modus POI-Typen lokal setzen
|
// POI-Typen laden
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (process.env.NEXT_PUBLIC_USE_MOCK_API === "true") {
|
if (process.env.NEXT_PUBLIC_USE_MOCK_API === "true") {
|
||||||
const mockData = [
|
console.warn("⚠️ POI-Typen im Mock-Modus – Redux-Thunk wird nicht ausgeführt.");
|
||||||
{ idPoiTyp: 1, name: "Mock Zähleranschlusskasten", icon: 4, onlySystemTyp: 0 },
|
|
||||||
{ idPoiTyp: 2, name: "Mock Geräteschrank", icon: 2, onlySystemTyp: 0 },
|
|
||||||
{ idPoiTyp: 4, name: "Mock Parkplatz", icon: 3, onlySystemTyp: 0 },
|
|
||||||
{ idPoiTyp: 6, name: "Mock Zufahrt", icon: 4, onlySystemTyp: 0 },
|
|
||||||
{ idPoiTyp: 20, name: "Mock Zählgerät", icon: 5, onlySystemTyp: 110 },
|
|
||||||
{ idPoiTyp: 21, name: "Mock Messschleife", icon: 6, onlySystemTyp: 110 },
|
|
||||||
{ idPoiTyp: 25, name: "Mock Sonstige", icon: 0, onlySystemTyp: 0 },
|
|
||||||
{ idPoiTyp: 33, name: "Mock Autobahnauffahrt", icon: 4, onlySystemTyp: null },
|
|
||||||
];
|
|
||||||
// Du kannst das Redux-Mock-Datenhandling später noch global regeln
|
|
||||||
console.warn("⚠️ POI-Typen im Mock-Modus geladen.");
|
|
||||||
} else if (poiTypStatus === "idle") {
|
} else if (poiTypStatus === "idle") {
|
||||||
dispatch(fetchPoiTypThunk());
|
dispatch(fetchPoiTypThunk());
|
||||||
}
|
}
|
||||||
}, [dispatch, poiTypStatus]);
|
}, [dispatch, poiTypStatus]);
|
||||||
|
|
||||||
// Geräte-Daten lokal laden (kann später durch fetchLocationDevicesThunk ersetzt werden)
|
// GIS Geräte laden
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchDeviceData = async () => {
|
dispatch(fetchGisStationsStaticDistrictThunk());
|
||||||
try {
|
}, [dispatch]);
|
||||||
const protocol = window.location.protocol;
|
|
||||||
const host = window.location.hostname;
|
|
||||||
const apiBaseUrl = `${protocol}//${host}/talas5/ClientData/WebServiceMap.asmx`;
|
|
||||||
|
|
||||||
const params = new URLSearchParams(window.location.search);
|
// PriorityConfig laden
|
||||||
const idMap = params.get("m");
|
useEffect(() => {
|
||||||
|
dispatch(fetchPriorityConfigThunk());
|
||||||
const url = `${apiBaseUrl}/GisStationsStatic?idMap=${idMap}`;
|
}, [dispatch]);
|
||||||
console.log("🌐 Geräte-API:", url);
|
|
||||||
|
|
||||||
const response = await fetch(url);
|
|
||||||
const data = await response.json();
|
|
||||||
|
|
||||||
setLocationDeviceData(data.Points || []);
|
|
||||||
if (data.Points && data.Points.length > 0) {
|
|
||||||
setDeviceName(data.Points[0].LD_Name);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error("❌ Fehler beim Abrufen der Gerätedaten:", error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
fetchDeviceData();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
poiTypData,
|
poiTypData,
|
||||||
isPoiTypLoaded: poiTypStatus === "succeeded",
|
isPoiTypLoaded: poiTypStatus === "succeeded",
|
||||||
deviceName,
|
deviceName,
|
||||||
setDeviceName,
|
|
||||||
locationDeviceData,
|
locationDeviceData,
|
||||||
setLocationDeviceData,
|
|
||||||
priorityConfig,
|
priorityConfig,
|
||||||
setPriorityConfig,
|
|
||||||
menuItemAdded,
|
menuItemAdded,
|
||||||
setMenuItemAdded,
|
setMenuItemAdded,
|
||||||
poiLayerVisible,
|
poiLayerVisible,
|
||||||
|
|||||||
Reference in New Issue
Block a user