fix(poi): Fehler beim Hinzufügen von POIs behoben (Modal blieb offen)

- Falsche URL im addPoiService korrigiert (/addLocation → /addPoi)
- Redux-Status wird nach erfolgreichem Hinzufügen zurückgesetzt (resetAddPoiStatus)
- Modal schließt jetzt zuverlässig nach dem Dispatch
- Ladeanzeige "Wird hinzugefügt..." verschwindet korrekt
- Version auf 1.1.176 erhöht
This commit is contained in:
ISA
2025-05-26 13:52:17 +02:00
parent ff55481273
commit cd46401f14
12 changed files with 162 additions and 81 deletions

View File

@@ -0,0 +1,37 @@
// pages/api/talas_v5_DB/pois/addPoi.js
import getPool from "../../../../utils/mysqlPool"; // Singleton-Pool importieren
export default async function handler(req, res) {
const pool = getPool(); // Singleton-Pool verwenden
if (req.method === "POST") {
const { name, poiTypeId, latitude, longitude, idLD } = req.body;
console.log("Received data:", req.body); // Überprüfen der empfangenen Daten
const query = "INSERT INTO poi (description, idPoiTyp, position, idLD) VALUES (?, ?, ST_GeomFromText(?),?)";
const point = `POINT(${longitude} ${latitude})`;
const values = [name, poiTypeId, point, idLD];
let connection;
try {
connection = await pool.getConnection(); // Hole eine Verbindung aus dem Pool
// Verwende die Verbindung, um die Query auszuführen
const [results] = await connection.query(query, values);
res.status(200).json({
id: results.insertId,
message: "Standort erfolgreich hinzugefügt",
});
} catch (error) {
console.error("Fehler beim Einfügen des Standorts:", error);
res.status(500).json({ error: "Ein Fehler ist aufgetreten" });
} finally {
if (connection) connection.release(); // Gib die Verbindung in den Pool zurück
}
} else {
res.setHeader("Allow", ["POST"]);
res.status(405).end(`Method ${req.method} Not Allowed`);
}
}