diff --git a/components/PoiUpdateModal.js b/components/PoiUpdateModal.js index 2b48214db..72c2da45d 100644 --- a/components/PoiUpdateModal.js +++ b/components/PoiUpdateModal.js @@ -19,6 +19,8 @@ const PoiUpdateModal = ({ onClose, poiData }) => { if (response.ok) { alert("POI wurde erfolgreich gelöscht."); onClose(); // Close the modal + //Browser neu laden, um die aktualisierte Liste anzuzeigen + window.location.reload(); } else { throw new Error("Fehler beim Löschen des POI."); } diff --git a/pages/api/updatePoi.js b/pages/api/updatePoi.js index a94fce1c9..c6b12c3a0 100644 --- a/pages/api/updatePoi.js +++ b/pages/api/updatePoi.js @@ -23,7 +23,7 @@ export default function handler(req, res) { return res.status(405).json({ error: "Nur POST Methode erlaubt" }); } - const { idPoi, description, idPoiTyp } = req.body; // Stellen Sie sicher, dass die Felder korrekt benannt sind + const { idPoi, description, idPoiTyp, idLD } = req.body; // Stellen Sie sicher, dass die Felder korrekt benannt sind console.log("Empfangene Daten:", req.body); // Loggen der empfangenen Daten zur Überprüfung @@ -32,18 +32,22 @@ export default function handler(req, res) { } const query = - "UPDATE talas_v5.poi SET description = ?, idPoiTyp = ? WHERE idPoi = ?"; - connection.query(query, [description, idPoiTyp, idPoi], (error, results) => { - if (error) { - console.error("Fehler beim Aktualisieren des POI:", error); - return res - .status(500) - .json({ error: "Fehler beim Aktualisieren des POI" }); + "UPDATE talas_v5.poi SET description = ?, idPoiTyp = ?, idLD WHERE idPoi = ?"; + connection.query( + query, + [description, idPoiTyp, idPoi, idLD], + (error, results) => { + if (error) { + console.error("Fehler beim Aktualisieren des POI:", error); + return res + .status(500) + .json({ error: "Fehler beim Aktualisieren des POI" }); + } + if (results.affectedRows > 0) { + res.json({ message: "POI erfolgreich aktualisiert" }); + } else { + res.status(404).json({ error: "POI nicht gefunden" }); + } } - if (results.affectedRows > 0) { - res.json({ message: "POI erfolgreich aktualisiert" }); - } else { - res.status(404).json({ error: "POI nicht gefunden" }); - } - }); + ); }