From 6885768bed6ac0380d29b73a2bf813c0ed69e373 Mon Sep 17 00:00:00 2001 From: ISA Date: Wed, 21 May 2025 14:23:45 +0200 Subject: [PATCH] =?UTF-8?q?refactor:=20DataSheet-Panel=20zeigt=20sich=20je?= =?UTF-8?q?tzt=20nur=20bei=20g=C3=BCltigen=20Redux-Daten?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - entferne lokalen fetch + isDataLoaded State - fetchGisStationsStaticDistrictThunk per Redux-Status 'idle' getriggert - Anzeige von DataSheet erfolgt nur, wenn GisStationsStaticDistrict.Points vorhanden sind --- CHANGELOG.md | 10 +++++ components/mainComponent/MapComponent.js | 52 +++--------------------- config/appVersion.js | 2 +- 3 files changed, 16 insertions(+), 48 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e848631a..7ea48c081 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ Alle bedeutenden Änderungen an diesem Projekt werden in dieser Datei dokumentie --- +## [1.1.132] – 2025-05-21 + +### Refactored + +- Entfernt: manuelle Fetch-Funktion und lokalen `isDataLoaded`-State für `DataSheet` +- Hinzugefügt: Anzeige des Panels erfolgt jetzt über Redux Store (`GisStationsStaticDistrict.Points`) +- Verbesserte Kontrolle über Sichtbarkeit der Layer-Steuerung auf Basis von Store-Daten + +--- + ## [1.1.130] – 2025-05-21 ### Changed diff --git a/components/mainComponent/MapComponent.js b/components/mainComponent/MapComponent.js index 9ac733b81..e8d2e20bb 100644 --- a/components/mainComponent/MapComponent.js +++ b/components/mainComponent/MapComponent.js @@ -796,50 +796,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { } }, [map]); //-------------------------------------------- - const fetchGisStationsStaticDistrict = async (idMap, idUser, dispatch) => { - try { - // API-Endpunkt mit Query-Parametern aufrufen - const response = await fetch(`/api/gisStationsStaticDistrict?m=${idMap}&u=${idUser}`); - if (!response.ok) { - throw new Error("Netzwerkantwort war nicht ok."); - } - - const data = await response.json(); - - // Ergebnis im Dispatch speichern oder State aktualisieren - dispatch({ type: "SET_GIS_STATIONS", payload: data }); - - //console.log("Daten erfolgreich geladen:", data); - return data; // Optional: Rückgabe der Daten - } catch (error) { - console.error("Fehler beim Laden der GIS-Daten:", error); - throw error; - } - }; - - const [isDataLoaded, setIsDataLoaded] = useState(false); - - useEffect(() => { - const fetchData = async () => { - try { - const idMap = 12; // Beispielwert für die Map-ID - const idUser = 484; // Beispielwert für die Benutzer-ID - - // Daten aus der API abrufen - await fetchGisStationsStaticDistrict(idMap, idUser, dispatch); - - setIsDataLoaded(true); // Daten erfolgreich geladen - } catch (error) { - console.error("Fehler beim Laden der Daten:", error); - setIsDataLoaded(false); // Fehler beim Laden - } - }; - - fetchData(); - }, [dispatch]); - - //-------------------------------------------- const handleCoordinatesSubmit = (coords) => { const [lat, lng] = coords.split(",").map(Number); if (map && lat && lng) { @@ -896,9 +853,10 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { }, [dispatch]); useEffect(() => { - dispatch(fetchGisStationsStaticDistrictThunk()); - }, [dispatch]); - + if (statusStaticDistrict === "idle") { + dispatch(fetchGisStationsStaticDistrictThunk()); + } + }, [statusStaticDistrict, dispatch]); useEffect(() => { dispatch(fetchGisStationsMeasurementsThunk()); }, [dispatch]); @@ -985,7 +943,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { )} - {isDataLoaded && } + {GisStationsStaticDistrict && GisStationsStaticDistrict.Points?.length > 0 && }
diff --git a/config/appVersion.js b/config/appVersion.js index a09a03c52..595614d35 100644 --- a/config/appVersion.js +++ b/config/appVersion.js @@ -1,2 +1,2 @@ // /config/appVersion -export const APP_VERSION = "1.1.131"; +export const APP_VERSION = "1.1.132";