idLD update done! muss noch Gerät und Typ gelesen von POI ins dropdown menu
This commit is contained in:
@@ -41,6 +41,8 @@ const PoiUpdateModal = ({ onClose, poiData }) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Beim Öffnen des Modals die Geräte-ID basierend auf dem Gerätenamen abrufen, wenn vorhanden
|
// Beim Öffnen des Modals die Geräte-ID basierend auf dem Gerätenamen abrufen, wenn vorhanden
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchDeviceId = async () => {
|
const fetchDeviceId = async () => {
|
||||||
@@ -122,10 +124,15 @@ const PoiUpdateModal = ({ onClose, poiData }) => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// Angenommen, deviceName enthält die Geräte-ID
|
// 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();
|
event.preventDefault();
|
||||||
|
const idLDResponse = await fetch(
|
||||||
|
`/api/getDeviceId?deviceName=${encodeURIComponent(deviceName)}`
|
||||||
|
);
|
||||||
|
const idLDData = await idLDResponse.json();
|
||||||
|
const idLD = idLDData.idLD;
|
||||||
try {
|
try {
|
||||||
const response = await fetch("/api/updatePoi", {
|
const response = await fetch("/api/updatePoi", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -137,7 +144,8 @@ const handleSubmit = async (event) => {
|
|||||||
name: name,
|
name: name,
|
||||||
description: description,
|
description: description,
|
||||||
idPoiTyp: poiTypeId,
|
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);
|
console.error("Fehler beim Aktualisieren des POI:", error);
|
||||||
alert("Fehler beim Aktualisieren des POI.");
|
alert("Fehler beim Aktualisieren des POI.");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -188,16 +196,13 @@ const handleSubmit = async (event) => {
|
|||||||
value={deviceName}
|
value={deviceName}
|
||||||
onChange={(e) => setDeviceName(e.target.value)}
|
onChange={(e) => setDeviceName(e.target.value)}
|
||||||
className="block p-2 w-full border-2 border-gray-200 rounded-md text-sm"
|
className="block p-2 w-full border-2 border-gray-200 rounded-md text-sm"
|
||||||
>
|
>
|
||||||
{locationDeviceData.map((device, index) => (
|
{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}
|
{device.name}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center mb-4">
|
<div className="flex items-center mb-4">
|
||||||
|
|||||||
Reference in New Issue
Block a user