Poi update, aber idLD muss noch gemacht werden

This commit is contained in:
ISA
2024-05-22 08:03:27 +02:00
parent 185d9348ea
commit a7eee8eccf
2 changed files with 59 additions and 24 deletions

View File

@@ -68,8 +68,33 @@ const PoiUpdateModal = ({ onClose, poiData }) => {
// Form submission handler
const handleSubmit = async (event) => {
event.preventDefault(); // Prevent the form from submitting
// Perform update operation here
event.preventDefault();
try {
const response = await fetch("/api/updatePoi", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
idPoi: poiId,
description: name,
idPoiTyp: poiTypeId,
}),
});
if (response.ok) {
alert("POI wurde erfolgreich aktualisiert.");
onClose(); // Schließen des Modals und Aktualisieren der Ansicht
} else {
const errorResponse = await response.json();
throw new Error(
errorResponse.error || "Fehler beim Aktualisieren des POI."
);
}
} catch (error) {
console.error("Fehler beim Aktualisieren des POI:", error);
alert("Fehler beim Aktualisieren des POI.");
}
};
return (