Gerät: name in dropdown menu
This commit is contained in:
@@ -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
|
||||
</button>
|
||||
<div>
|
||||
{deviceName ? <p>Gerätename: {deviceName}</p> : <p>Gerätename wird geladen...</p>}
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user