diff --git a/components/AddPOIModal.js b/components/AddPOIModal.js
index fa1a07077..9841d0078 100644
--- a/components/AddPOIModal.js
+++ b/components/AddPOIModal.js
@@ -20,17 +20,18 @@ const ShowAddStationPopup = ({ onClose, map, latlng }) => {
const setLoadData = useSetRecoilState(readPoiMarkersStore);
const setTrigger = useSetRecoilState(poiReadFromDbTriggerAtom);
const [deviceName, setDeviceName] = useState("");
-
+ //-----------------------------------------------------
useEffect(() => {
const fetchpoiTypData = async () => {
try {
const response = await fetch("/api/talas_v5_DB/poiTyp/readPoiTyp");
const data = await response.json();
setpoiTypData(data);
+
if (data && data.length > 0) {
- setPoiTypeId(data[0].idPoiTyp); // Set initial poiTypeId to the id of the first poiType
- setPoiTypeName(data[1].name); // Set initial poiTypeName to the name of the first poiType
- console.log("Initial poiTypeId set in ShowAddStationPopup.js :", data[0].idPoiTyp);
+ console.log("POI-Typen geladen:", data);
+ setPoiTypeId(data[0].idPoiTyp); // Setzt den ersten Typ
+ setPoiTypeName(data[0].name);
}
} catch (error) {
console.error("Fehler beim Abrufen der poiTyp Daten:", error);
@@ -39,6 +40,16 @@ const ShowAddStationPopup = ({ onClose, map, latlng }) => {
fetchpoiTypData();
}, []);
+
+ useEffect(() => {
+ if (poiTypData.length > 0 && !poiTypeId) {
+ setPoiTypeId(poiTypData[0].idPoiTyp);
+ }
+ }, [poiTypData]);
+ useEffect(() => {
+ console.log("Aktueller POI Type:", poiTypeId);
+ }, [poiTypeId]);
+
//------------------------------------------------------------------------------------------
const gisStationsStatic = useSelector(selectGisStationsStatic);
const locationDeviceData = gisStationsStatic?.Points ?? [];
@@ -58,7 +69,7 @@ const ShowAddStationPopup = ({ onClose, map, latlng }) => {
event.preventDefault();
const formData = {
name,
- poiTypeId,
+ poiTypeId: Number(poiTypeId), // Umwandlung in eine Zahl
latitude,
longitude,
idLD: locationDeviceData.find((device) => device.LD_Name === deviceName)?.IdLD,
@@ -134,12 +145,24 @@ const ShowAddStationPopup = ({ onClose, map, latlng }) => {
-