From f949272371c02cf94682196ad038d82fad44534c Mon Sep 17 00:00:00 2001 From: isa Date: Sun, 26 May 2024 15:48:31 +0200 Subject: [PATCH] =?UTF-8?q?Ger=C3=A4t:=20name=20in=20dropdown=20menu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/PoiUpdateModal.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/components/PoiUpdateModal.js b/components/PoiUpdateModal.js index 987e85396..71c0b0193 100644 --- a/components/PoiUpdateModal.js +++ b/components/PoiUpdateModal.js @@ -3,9 +3,12 @@ import React, { useState, useEffect } from "react"; import { useRecoilValue } from "recoil"; import { selectedPoiState } from "../store/atoms/poiState"; +import { currentPoiState } from '../store/atoms/currentPoiState'; const PoiUpdateModal = ({ onClose, poiData }) => { + + const currentPoi = useRecoilValue(currentPoiState); const selectedPoi = useRecoilValue(selectedPoiState); const [poiId, setPoiId] = useState(poiData ? poiData.idPoi : ""); const [name, setName] = useState(poiData ? poiData.name : ""); @@ -152,6 +155,7 @@ const PoiUpdateModal = ({ onClose, poiData }) => { // Fetch device name basierend auf der Geräte-ID useEffect(() => { + console.log("currentPoi von PoiUpdateModal.js : ", currentPoi.idLD); fetch('/api/locationDevices') .then(response => response.json()) .then(data => { @@ -159,7 +163,7 @@ useEffect(() => { console.log("Standort- und Gerätedaten 3:", data); console.log("Standort- und Gerätedaten 3 poiData:", poiData); // Findet das Gerät, das der aktuellen IDLD entspricht - const currentDevice = data.find(device => device.idLD === poiData?.idLD); + const currentDevice = data.find(device => device.idLD === currentPoi.idLD); if (currentDevice) { setDeviceName(currentDevice.name); } @@ -168,7 +172,7 @@ useEffect(() => { console.error('Fehler beim Abrufen der Gerätedaten:', error); setLocationDeviceData([]); }); -}, [poiData?.idLD]); +}, [poiData?.idLD,currentPoi]); //-------------------------------------------------------------------------------------------- @@ -290,9 +294,6 @@ useEffect(() => { > POI aktualisieren -
- {deviceName ?

Gerätename: {deviceName}

:

Gerätename wird geladen...

} -
); };