refactor: DataSheet-Panel zeigt sich jetzt nur bei gültigen Redux-Daten
- entferne lokalen fetch + isDataLoaded State - fetchGisStationsStaticDistrictThunk per Redux-Status 'idle' getriggert - Anzeige von DataSheet erfolgt nur, wenn GisStationsStaticDistrict.Points vorhanden sind
This commit is contained in:
10
CHANGELOG.md
10
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
|
||||
|
||||
@@ -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 }) => {
|
||||
)}
|
||||
</div>
|
||||
|
||||
{isDataLoaded && <DataSheet className="z-50" />}
|
||||
{GisStationsStaticDistrict && GisStationsStaticDistrict.Points?.length > 0 && <DataSheet className="z-50" />}
|
||||
|
||||
<CoordinateInput onCoordinatesSubmit={handleCoordinatesSubmit} />
|
||||
<div id="map" ref={mapRef} className="z-0" style={{ height: "100vh", width: "100vw" }}></div>
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
// /config/appVersion
|
||||
export const APP_VERSION = "1.1.131";
|
||||
export const APP_VERSION = "1.1.132";
|
||||
|
||||
Reference in New Issue
Block a user