fix: POI löschen in PoiUpdateModal.js hinzugefügt
This commit is contained in:
@@ -80,6 +80,25 @@ const PoiUpdateModal = ({ onClose, poiData, onSubmit }) => {
|
|||||||
fetchLocationDevices();
|
fetchLocationDevices();
|
||||||
}, [poiData]);
|
}, [poiData]);
|
||||||
|
|
||||||
|
const handleDeletePoi = async () => {
|
||||||
|
if (confirm("Sind Sie sicher, dass Sie diesen POI löschen möchten?")) {
|
||||||
|
try {
|
||||||
|
const response = await fetch(`/api/talas_v5_DB/pois/deletePoi?id=${poiId}`, {
|
||||||
|
method: "DELETE",
|
||||||
|
});
|
||||||
|
if (response.ok) {
|
||||||
|
onClose();
|
||||||
|
window.location.reload();
|
||||||
|
} else {
|
||||||
|
throw new Error("Fehler beim Löschen des POI.");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Fehler beim Löschen des POI:", error);
|
||||||
|
alert("Fehler beim Löschen des POI.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleSubmit = async (event) => {
|
const handleSubmit = async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const idLDResponse = await fetch(`/api/talas_v5_DB/locationDevice/getDeviceId?deviceName=${encodeURIComponent(deviceName)}`);
|
const idLDResponse = await fetch(`/api/talas_v5_DB/locationDevice/getDeviceId?deviceName=${encodeURIComponent(deviceName)}`);
|
||||||
@@ -155,7 +174,9 @@ const PoiUpdateModal = ({ onClose, poiData, onSubmit }) => {
|
|||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<button type="button" onClick={handleDeletePoi} className="bg-red-400 hover:bg-red-600 text-white font-bold py-2 px-4 rounded w-full mb-4">
|
||||||
|
POI löschen
|
||||||
|
</button>
|
||||||
<button type="submit" className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded w-full">
|
<button type="submit" className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded w-full">
|
||||||
POI aktualisieren
|
POI aktualisieren
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user