feat: POI-Erstellung, -Bearbeitung und -Löschung vollständig überarbeitet

- POI-Tooltip zeigt jetzt den korrekten Gerätenamen aus Redux (gisStationsStaticDistrict)
- Bearbeitungsmodal (PoiUpdateModal) verwendet Redux-Daten (idLD → Gerätelabel) zur Initialisierung
- Fix: Geräte-Dropdown im Modal zeigt nun den ausgewählten POI korrekt an
- Refactor: `handleUpdatePoi()` nutzt `description` statt `name`
- Fehlerbehandlung im Modal verbessert (alert bei leerem Feld, besseres Logging)
- Redux-Thunk `updatePoiThunk` + `updatePoiService` stabilisiert
- Map aktualisiert POIs nach Bearbeitung automatisch

📦 Version erhöht auf 1.1.253
🗓️ 11.06.2025
This commit is contained in:
ISA
2025-06-11 07:41:10 +02:00
parent 8e5dac82b5
commit 0a97c359d8
11 changed files with 76 additions and 56 deletions

View File

@@ -8,7 +8,6 @@ import { selectMapLayersState } from "@/redux/slices/mapLayersSlice";
import { selectPoiTypData, selectPoiTypStatus } from "@/redux/slices/database/pois/poiTypSlice";
import { deletePoiThunk } from "@/redux/thunks/database/pois/deletePoiThunk";
import { updatePoiThunk } from "@/redux/thunks/database/pois/updatePoiThunk";
import { selectSelectedPoi } from "@/redux/slices/database/pois/selectedPoiSlice";
import { handleSubmit } from "@/components/pois/poiUpdateModal/utils/handlers";
import { selectCurrentPoi } from "@/redux/slices/database/pois/currentPoiSlice";
import { selectGisStationsStaticDistrict } from "@/redux/slices/webservice/gisStationsStaticDistrictSlice";
@@ -56,17 +55,6 @@ const PoiUpdateModal = ({ onClose, poiData }) => {
}
}, [dispatch, poiTypStatus]);
/* useEffect(() => {
console.log("devices in PoiUpdateModal:", devices);
if (poi && devices.length > 0) {
const selectedDevice = devices.find(device => Number(device.idLD) === Number(poi.idLD));
console.log("Selected Device:", selectedDevice);
if (selectedDevice) {
setDeviceName({ value: selectedDevice.idLD, label: selectedDevice.name });
}
}
}, [poi, devices]); */
useEffect(() => {
console.log("poiTypData in PoiUpdateModal:", poiTypData);
if (poi && poiTypData.length > 0) {
@@ -80,13 +68,13 @@ const PoiUpdateModal = ({ onClose, poiData }) => {
useEffect(() => {
console.log("availableDevices in PoiUpdateModal:", availableDevices);
if (poiData && availableDevices.length > 0) {
const selectedDevice = availableDevices.find(device => device.idLD === poiData.idLD);
if (poi && availableDevices.length > 0) {
const selectedDevice = availableDevices.find(device => device.IdLD === poi.idLD);
if (selectedDevice) {
setDeviceName({ value: selectedDevice.idLD, label: selectedDevice.LD_Name }); // ✅ auch hier korrigieren
setDeviceName({ value: selectedDevice.IdLD, label: selectedDevice.LD_Name });
}
}
}, [poiData, availableDevices]);
}, [poi, availableDevices]);
const filterDevices = () => {
const activeSystems = Object.keys(mapLayersVisibility).filter(
@@ -106,7 +94,7 @@ const PoiUpdateModal = ({ onClose, poiData }) => {
: [];
const deviceOptions = availableDevices.map(device => ({
value: device.idLD,
value: device.IdLD,
label: device.LD_Name,
}));
@@ -153,7 +141,22 @@ const PoiUpdateModal = ({ onClose, poiData }) => {
/>
</svg>
</button>
<form onSubmit={handleSubmit} className="m-0 p-2 w-full">
<form
onSubmit={event =>
handleSubmit({
event,
dispatch,
poiId,
name,
description,
poiTypeId,
deviceName,
poi,
onClose,
})
}
className="m-0 p-2 w-full"
>
<div className="flex flex-col mb-4">
<label htmlFor="description" className="block mb-2 font-bold text-sm text-gray-700">
Beschreibung:

View File

@@ -1,8 +1,11 @@
// @/components/pois/poiUpdateModal/utils/handlers.js
import { updatePoiThunk } from "@/redux/thunks/database/pois/updatePoiThunk";
import { deletePoiThunk } from "@/redux/thunks/database/pois/deletePoiThunk";
export const handleSubmit = async ({
event,
dispatch,
poiId,
name,
description,
poiTypeId,
deviceName,
@@ -10,16 +13,18 @@ export const handleSubmit = async ({
onClose,
}) => {
event.preventDefault();
const payload = {
idPoi: poiId,
name: description, // 💡 <- Das ist die entscheidende Änderung!
description,
idPoiTyp: poiTypeId?.value ?? poi?.idPoiTyp,
idLD: deviceName?.value,
};
console.log("🔍 POI Update Payload:", payload);
try {
await dispatch(
updatePoiThunk({
idPoi: poiId,
name,
description,
idPoiTyp: poiTypeId?.value ?? poi?.idPoiTyp,
idLD: deviceName?.value,
})
).unwrap();
await dispatch(updatePoiThunk(payload)).unwrap();
onClose();
window.location.reload();
} catch (error) {