refactor: PoiUpdateModal auf Redux poiTypSlice umgestellt
- fetch(...) durch fetchPoiTypThunk ersetzt - Zugriff auf POI-Typen über selectPoiTypData - Code vereinheitlicht mit AddPOIModal.js - Version erhöht auf 1.1.160
This commit is contained in:
19
CHANGELOG.md
19
CHANGELOG.md
@@ -4,6 +4,25 @@ Alle bedeutenden Änderungen an diesem Projekt werden in dieser Datei dokumentie
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## [1.1.160] – 2025-05-23
|
||||||
|
|
||||||
|
### ♻️ Refactor
|
||||||
|
|
||||||
|
- `PoiUpdateModal.js` umgestellt auf Redux `poiTypSlice`
|
||||||
|
- Direkter `fetch("/api/talas_v5_DB/poiTyp/readPoiTyp")` entfernt
|
||||||
|
- POI-Typen jetzt über `fetchPoiTypThunk` geladen
|
||||||
|
|
||||||
|
### 🧠 Architektur
|
||||||
|
|
||||||
|
- POI-Typen einheitlich über Redux-Store statt lokalem State
|
||||||
|
- `poiTypData` kommt nun aus `selectPoiTypData` (Redux)
|
||||||
|
|
||||||
|
### 🔧 Version
|
||||||
|
|
||||||
|
- 📦 Version erhöht auf **1.1.160**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## [1.1.159] – 2025-05-23
|
## [1.1.159] – 2025-05-23
|
||||||
|
|
||||||
### 🐞 Fixed
|
### 🐞 Fixed
|
||||||
|
|||||||
@@ -4,18 +4,21 @@ import Select from "react-select"; // Importiere react-select
|
|||||||
import { fetchLocationDevicesThunk } from "../../redux/thunks/database/fetchLocationDevicesThunk";
|
import { fetchLocationDevicesThunk } from "../../redux/thunks/database/fetchLocationDevicesThunk";
|
||||||
import { useSelector, useDispatch } from "react-redux";
|
import { useSelector, useDispatch } from "react-redux";
|
||||||
import { selectMapLayersState } from "../../redux/slices/mapLayersSlice";
|
import { selectMapLayersState } from "../../redux/slices/mapLayersSlice";
|
||||||
|
import { fetchPoiTypThunk } from "../../redux/thunks/database/fetchPoiTypThunk";
|
||||||
|
import { selectPoiTypData, selectPoiTypStatus } from "../../redux/slices/database/poiTypSlice";
|
||||||
|
|
||||||
const PoiUpdateModal = ({ onClose, poiData, onSubmit }) => {
|
const PoiUpdateModal = ({ onClose, poiData, onSubmit }) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const mapLayersVisibility = useSelector(selectMapLayersState);
|
const mapLayersVisibility = useSelector(selectMapLayersState);
|
||||||
const [poiId, setPoiId] = useState(poiData ? poiData.idPoi : "");
|
const [poiId, setPoiId] = useState(poiData ? poiData.idPoi : "");
|
||||||
const [name, setName] = useState(poiData ? poiData.name : "");
|
const [name, setName] = useState(poiData ? poiData.name : "");
|
||||||
const [poiTypData, setPoiTypData] = useState([]);
|
|
||||||
const [poiTypeId, setPoiTypeId] = useState(null); // Verwende null für react-select
|
const [poiTypeId, setPoiTypeId] = useState(null); // Verwende null für react-select
|
||||||
const [filteredDevices, setFilteredDevices] = useState([]);
|
const [filteredDevices, setFilteredDevices] = useState([]);
|
||||||
const [deviceName, setDeviceName] = useState(poiData ? poiData.deviceName : null); // Verwende null für react-select
|
const [deviceName, setDeviceName] = useState(poiData ? poiData.deviceName : null); // Verwende null für react-select
|
||||||
const [idLD, setIdLD] = useState(poiData ? poiData.idLD : "");
|
const [idLD, setIdLD] = useState(poiData ? poiData.idLD : "");
|
||||||
const [description, setDescription] = useState(poiData ? poiData.description : "");
|
const [description, setDescription] = useState(poiData ? poiData.description : "");
|
||||||
|
const poiTypData = useSelector(selectPoiTypData);
|
||||||
|
const poiTypStatus = useSelector(selectPoiTypStatus);
|
||||||
|
|
||||||
// Map von Systemnamen zu IDs (wie zuvor)
|
// Map von Systemnamen zu IDs (wie zuvor)
|
||||||
const systemNameToIdMap = {
|
const systemNameToIdMap = {
|
||||||
@@ -55,34 +58,10 @@ const PoiUpdateModal = ({ onClose, poiData, onSubmit }) => {
|
|||||||
|
|
||||||
// Fetch POI types and set the current POI type in the react-select dropdown
|
// Fetch POI types and set the current POI type in the react-select dropdown
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchPoiTypData = async () => {
|
if (poiTypStatus === "idle") {
|
||||||
try {
|
dispatch(fetchPoiTypThunk());
|
||||||
const response = await fetch("/api/talas_v5_DB/poiTyp/readPoiTyp");
|
}
|
||||||
const data = await response.json();
|
}, [dispatch, poiTypStatus]);
|
||||||
setPoiTypData(data);
|
|
||||||
|
|
||||||
// Prüfe den gespeicherten Typ im localStorage
|
|
||||||
const storedPoiType = localStorage.getItem("selectedPoiType");
|
|
||||||
|
|
||||||
// Finde den passenden Typ in den abgerufenen Daten und setze ihn als ausgewählt
|
|
||||||
if (storedPoiType) {
|
|
||||||
const matchingType = data.find((type) => type.name === storedPoiType);
|
|
||||||
if (matchingType) {
|
|
||||||
setPoiTypeId({ value: matchingType.idPoiTyp, label: matchingType.name });
|
|
||||||
}
|
|
||||||
} else if (poiData && poiData.idPoiTyp) {
|
|
||||||
// Falls kein Typ im localStorage ist, setze den Typ von poiData
|
|
||||||
const matchingType = data.find((type) => type.idPoiTyp === poiData.idPoiTyp);
|
|
||||||
if (matchingType) {
|
|
||||||
setPoiTypeId({ value: matchingType.idPoiTyp, label: matchingType.name });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Fehler beim Abrufen der poiTyp Daten:", error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
fetchPoiTypData();
|
|
||||||
}, [poiData]);
|
|
||||||
|
|
||||||
// Fetch location devices and pre-select the current device
|
// Fetch location devices and pre-select the current device
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
// /config/appVersion
|
// /config/appVersion
|
||||||
export const APP_VERSION = "1.1.160";
|
export const APP_VERSION = "1.1.161";
|
||||||
|
|||||||
Reference in New Issue
Block a user