refactor: React-Hooks entfernt und durch Redux ersetzt (v1.1.101)
This commit is contained in:
17
CHANGELOG.md
17
CHANGELOG.md
@@ -4,6 +4,23 @@ Alle bedeutenden Änderungen an diesem Projekt werden in dieser Datei dokumentie
|
||||
|
||||
---
|
||||
|
||||
## [1.1.101] – 2025-05-19
|
||||
|
||||
### Removed
|
||||
|
||||
- 🧼 Redundante React-Hooks entfernt, da Funktionalität vollständig in Redux abgebildet ist:
|
||||
- `useFetchPriorityConfig.js`
|
||||
- `useFetchUserRights.js`
|
||||
- `useFetchWebServiceMap.js`
|
||||
- `useFetchLineStatusData.js`
|
||||
|
||||
### Refactor
|
||||
|
||||
- 🔁 Vorbereitung zur Aufteilung von `useLineData.js` und `useMapComponentState.js` in separate Redux-Slices & spezialisierte Hooks
|
||||
- 🟡 Validierte React-Hooks beibehalten (z. B. Marker-Handling & Layer-Logik)
|
||||
|
||||
---
|
||||
|
||||
## [1.1.100] – 2025-05-19
|
||||
|
||||
### Added
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
// /config/appVersion
|
||||
export const APP_VERSION = "1.1.101";
|
||||
export const APP_VERSION = "1.1.102";
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
import { useEffect } from "react";
|
||||
|
||||
export const useFetchLineStatusData = (
|
||||
webserviceGisLinesStatusUrl,
|
||||
setLineStatusData,
|
||||
setLinesData
|
||||
) => {
|
||||
useEffect(() => {
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
const response1 = await fetch(webserviceGisLinesStatusUrl);
|
||||
const data1 = await response1.json();
|
||||
const reversedData = data1.Statis.reverse();
|
||||
setLineStatusData(reversedData);
|
||||
|
||||
const response2 = await fetch("/api/talas_v5_DB/gisLines/readGisLines");
|
||||
const data2 = await response2.json();
|
||||
|
||||
const colorsByModule = {};
|
||||
reversedData.forEach((stat) => {
|
||||
const matchingLine = data2.find(
|
||||
(item) => item.idLD === stat.IdLD && item.idModul === stat.Modul
|
||||
);
|
||||
if (matchingLine) {
|
||||
colorsByModule[matchingLine.idModul] = stat.PrioColor;
|
||||
setLinesData(matchingLine);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Error fetching data:", error);
|
||||
}
|
||||
};
|
||||
fetchData();
|
||||
}, [webserviceGisLinesStatusUrl, setLineStatusData, setLinesData]);
|
||||
};
|
||||
@@ -1,20 +0,0 @@
|
||||
import { useEffect } from "react";
|
||||
|
||||
export const useFetchPriorityConfig = (setPriorityConfig) => {
|
||||
useEffect(() => {
|
||||
const fetchPriorityConfig = async () => {
|
||||
try {
|
||||
const res = await fetch("/api/talas_v5_DB/priorityConfig");
|
||||
if (!res.ok) {
|
||||
throw new Error(`HTTP error! status: ${res.status}`);
|
||||
}
|
||||
const data = await res.json();
|
||||
setPriorityConfig(data);
|
||||
} catch (error) {
|
||||
console.error("Failed to load priority configuration:", error);
|
||||
}
|
||||
};
|
||||
|
||||
fetchPriorityConfig();
|
||||
}, [setPriorityConfig]);
|
||||
};
|
||||
@@ -1,21 +0,0 @@
|
||||
import { useEffect } from "react";
|
||||
import { fetchUserRights } from "../services/api/fetchUserRights.js";
|
||||
|
||||
export const useFetchUserRights = (setUserRights, setIsRightsLoaded, setHasRights) => {
|
||||
useEffect(() => {
|
||||
const fetchAndSetUserRights = async () => {
|
||||
try {
|
||||
const rights = await fetchUserRights();
|
||||
setUserRights(rights);
|
||||
setIsRightsLoaded(true);
|
||||
|
||||
// Sicherstellen, dass `rights` ein Array ist, bevor `.includes()` aufgerufen wird
|
||||
setHasRights(localStorage.getItem("editMode") && Array.isArray(rights) && rights.includes(56));
|
||||
} catch (error) {
|
||||
console.error("Fehler beim Abrufen der Benutzerrechte:", error);
|
||||
}
|
||||
};
|
||||
|
||||
fetchAndSetUserRights();
|
||||
}, [setUserRights, setIsRightsLoaded, setHasRights]);
|
||||
};
|
||||
@@ -1,59 +0,0 @@
|
||||
// /hooks/useFetchWebServiceMap.js
|
||||
import { useEffect } from "react";
|
||||
import { fetchGisStationsStaticDistrict } from "../services/api/fetchGisStationsStaticDistrict";
|
||||
import { fetchGisStationsStatusDistrict } from "../services/api/fetchGisStationsStatusDistrict";
|
||||
import { fetchGisStationsMeasurements } from "../services/api/fetchGisStationsMeasurements";
|
||||
import { fetchGisSystemStatic } from "../services/api/fetchGisSystemStatic";
|
||||
|
||||
export const useFetchWebServiceMap = (
|
||||
dispatch,
|
||||
mapGisStationsStaticDistrictUrl,
|
||||
mapGisStationsStatusDistrictUrl,
|
||||
mapGisStationsMeasurementsUrl,
|
||||
mapGisSystemStaticUrl,
|
||||
setGisStationsStatusDistrict,
|
||||
setGisStationsMeasurements,
|
||||
setGisSystemStatic,
|
||||
setGisSystemStaticLoaded
|
||||
) => {
|
||||
useEffect(() => {
|
||||
const fetchWebServiceMap = async () => {
|
||||
try {
|
||||
// Zähler für externe API-Aufrufe in localStorage speichern
|
||||
let requestCount = localStorage.getItem("fetchWebServiceMap") || 0;
|
||||
requestCount = parseInt(requestCount, 10);
|
||||
|
||||
const fetchOptions = {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Connection: "close",
|
||||
},
|
||||
};
|
||||
|
||||
// Fetch GIS Stations Static District
|
||||
await fetchGisStationsStaticDistrict(mapGisStationsStaticDistrictUrl, dispatch, fetchOptions);
|
||||
requestCount++;
|
||||
localStorage.setItem("fetchWebServiceMap", requestCount);
|
||||
|
||||
// Fetch GIS Stations Status District
|
||||
await fetchGisStationsStatusDistrict(mapGisStationsStatusDistrictUrl, setGisStationsStatusDistrict, fetchOptions);
|
||||
requestCount++;
|
||||
localStorage.setItem("fetchWebServiceMap", requestCount);
|
||||
|
||||
// Fetch GIS Stations Measurements
|
||||
await fetchGisStationsMeasurements(mapGisStationsMeasurementsUrl, setGisStationsMeasurements, fetchOptions);
|
||||
requestCount++;
|
||||
localStorage.setItem("fetchWebServiceMap", requestCount);
|
||||
|
||||
// Fetch GIS System Static
|
||||
await fetchGisSystemStatic(mapGisSystemStaticUrl, setGisSystemStatic, setGisSystemStaticLoaded, fetchOptions);
|
||||
requestCount++;
|
||||
localStorage.setItem("fetchWebServiceMap", requestCount);
|
||||
} catch (error) {
|
||||
console.error("Error fetching data:", error);
|
||||
}
|
||||
};
|
||||
|
||||
fetchWebServiceMap();
|
||||
}, [dispatch, mapGisStationsStaticDistrictUrl, mapGisStationsStatusDistrictUrl, mapGisStationsMeasurementsUrl, mapGisSystemStaticUrl, setGisStationsStatusDistrict, setGisStationsMeasurements, setGisSystemStatic, setGisSystemStaticLoaded]);
|
||||
};
|
||||
Reference in New Issue
Block a user