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 () => {
@@ -126,6 +128,11 @@ const idLD = deviceName; // Stellen Sie sicher, dass dies eine ID ist und kein N
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
}),
});
@@ -190,14 +198,11 @@ const handleSubmit = async (event) => {
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>
</div>
<div className="flex items-center mb-4">