idLD update done! muss noch Gerät und Typ gelesen von POI ins dropdown menu

This commit is contained in:
isa
2024-05-22 22:49:38 +02:00
parent 112467e22c
commit 5cad5df44a

View File

@@ -41,6 +41,8 @@ const PoiUpdateModal = ({ onClose, poiData }) => {
}
};
// Beim Öffnen des Modals die Geräte-ID basierend auf dem Gerätenamen abrufen, wenn vorhanden
useEffect(() => {
const fetchDeviceId = async () => {
@@ -122,10 +124,15 @@ const PoiUpdateModal = ({ onClose, poiData }) => {
}, []);
// Angenommen, deviceName enthält die Geräte-ID
const idLD = deviceName; // Stellen Sie sicher, dass dies eine ID ist und kein Name
const idLD = deviceName; // Stellen Sie sicher, dass dies eine ID ist und kein Name
const handleSubmit = async (event) => {
const handleSubmit = async (event) => {
event.preventDefault();
const idLDResponse = await fetch(
`/api/getDeviceId?deviceName=${encodeURIComponent(deviceName)}`
);
const idLDData = await idLDResponse.json();
const idLD = idLDData.idLD;
try {
const response = await fetch("/api/updatePoi", {
method: "POST",
@@ -137,7 +144,8 @@ const handleSubmit = async (event) => {
name: name,
description: description,
idPoiTyp: poiTypeId,
idLD: parseInt(deviceName, 10), // Konvertieren in eine Ganzzahl
idLD: idLD,
//idLD: parseInt(deviceName, 10), // Konvertieren in eine Ganzzahl
}),
});
@@ -154,7 +162,7 @@ const handleSubmit = async (event) => {
console.error("Fehler beim Aktualisieren des POI:", error);
alert("Fehler beim Aktualisieren des POI.");
}
};
};
@@ -188,16 +196,13 @@ const handleSubmit = async (event) => {
value={deviceName}
onChange={(e) => setDeviceName(e.target.value)}
className="block p-2 w-full border-2 border-gray-200 rounded-md text-sm"
>
>
{locationDeviceData.map((device, index) => (
<option key={index} value={device.id}> {/* Stellen Sie sicher, dass device.id eine Ganzzahl ist */}
<option key={index} value={device.name}>
{device.name}
</option>
))}
</select>
</select>
</div>
<div className="flex items-center mb-4">