WIP: POI Update Modal, Beschreibung und Gerät funktioniert wie erweitet, Typ soll auch den gewählte POI Typ zuerst in dropdown angezeigt wird
This commit is contained in:
@@ -16,6 +16,15 @@ const PoiUpdateModal = ({ onClose, poiData, onSubmit }) => {
|
||||
const [idLD, setIdLD] = useState(poiData ? poiData.idLD : "");
|
||||
const [description, setDescription] = useState(poiData ? poiData.description : "");
|
||||
|
||||
// Debugging
|
||||
useEffect(() => {
|
||||
console.log("poiData:", poiData);
|
||||
if (!poiData.idLD) {
|
||||
console.error("Fehlender idLD in poiData");
|
||||
console.log("poiData:", poiData);
|
||||
}
|
||||
}, [poiData]);
|
||||
|
||||
// Fetch and set POI data
|
||||
useEffect(() => {
|
||||
if (poiData) {
|
||||
@@ -24,6 +33,7 @@ const PoiUpdateModal = ({ onClose, poiData, onSubmit }) => {
|
||||
setPoiTypeId(poiData.idPoiTyp);
|
||||
setIdLD(poiData.idLD);
|
||||
setDescription(poiData.description);
|
||||
console.log("Initial Device ID (idLD):", poiData.idLD);
|
||||
}
|
||||
}, [poiData]);
|
||||
|
||||
@@ -61,22 +71,13 @@ const PoiUpdateModal = ({ onClose, poiData, onSubmit }) => {
|
||||
if (cachedDeviceData) {
|
||||
const data = JSON.parse(cachedDeviceData);
|
||||
setLocationDeviceData(data);
|
||||
if (poiData) {
|
||||
if (poiData && poiData.idLD) {
|
||||
const selectedDevice = data.find((device) => device.idLD === poiData.idLD);
|
||||
setDeviceName(selectedDevice ? selectedDevice.name : ""); // Pre-select the current device
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
const response = await fetch("/api/talas_v5_DB/locationDevice/locationDevices");
|
||||
const data = await response.json();
|
||||
setLocationDeviceData(data);
|
||||
localStorage.setItem("locationDeviceData", JSON.stringify(data));
|
||||
if (poiData) {
|
||||
const selectedDevice = data.find((device) => device.idLD === poiData.idLD);
|
||||
setDeviceName(selectedDevice ? selectedDevice.name : ""); // Pre-select the current device
|
||||
console.log("Selected Device:", selectedDevice); // Debugging
|
||||
setDeviceName(selectedDevice ? selectedDevice.name : "");
|
||||
if (!selectedDevice) {
|
||||
console.error(`Kein Gerät mit idLD: ${poiData.idLD} gefunden.`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Fehler beim Abrufen der Standort- und Gerätedaten:", error);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user