Gerät: name in dropdown menu
This commit is contained in:
@@ -3,9 +3,12 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import { useRecoilValue } from "recoil";
|
import { useRecoilValue } from "recoil";
|
||||||
import { selectedPoiState } from "../store/atoms/poiState";
|
import { selectedPoiState } from "../store/atoms/poiState";
|
||||||
|
import { currentPoiState } from '../store/atoms/currentPoiState';
|
||||||
|
|
||||||
|
|
||||||
const PoiUpdateModal = ({ onClose, poiData }) => {
|
const PoiUpdateModal = ({ onClose, poiData }) => {
|
||||||
|
|
||||||
|
const currentPoi = useRecoilValue(currentPoiState);
|
||||||
const selectedPoi = useRecoilValue(selectedPoiState);
|
const selectedPoi = useRecoilValue(selectedPoiState);
|
||||||
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 : "");
|
||||||
@@ -152,6 +155,7 @@ const PoiUpdateModal = ({ onClose, poiData }) => {
|
|||||||
// Fetch device name basierend auf der Geräte-ID
|
// Fetch device name basierend auf der Geräte-ID
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
console.log("currentPoi von PoiUpdateModal.js : ", currentPoi.idLD);
|
||||||
fetch('/api/locationDevices')
|
fetch('/api/locationDevices')
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
@@ -159,7 +163,7 @@ useEffect(() => {
|
|||||||
console.log("Standort- und Gerätedaten 3:", data);
|
console.log("Standort- und Gerätedaten 3:", data);
|
||||||
console.log("Standort- und Gerätedaten 3 poiData:", poiData);
|
console.log("Standort- und Gerätedaten 3 poiData:", poiData);
|
||||||
// Findet das Gerät, das der aktuellen IDLD entspricht
|
// 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) {
|
if (currentDevice) {
|
||||||
setDeviceName(currentDevice.name);
|
setDeviceName(currentDevice.name);
|
||||||
}
|
}
|
||||||
@@ -168,7 +172,7 @@ useEffect(() => {
|
|||||||
console.error('Fehler beim Abrufen der Gerätedaten:', error);
|
console.error('Fehler beim Abrufen der Gerätedaten:', error);
|
||||||
setLocationDeviceData([]);
|
setLocationDeviceData([]);
|
||||||
});
|
});
|
||||||
}, [poiData?.idLD]);
|
}, [poiData?.idLD,currentPoi]);
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------
|
||||||
@@ -290,9 +294,6 @@ useEffect(() => {
|
|||||||
>
|
>
|
||||||
POI aktualisieren
|
POI aktualisieren
|
||||||
</button>
|
</button>
|
||||||
<div>
|
|
||||||
{deviceName ? <p>Gerätename: {deviceName}</p> : <p>Gerätename wird geladen...</p>}
|
|
||||||
</div>
|
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user