delete listing

This commit is contained in:
2025-02-15 18:50:30 +08:00
parent ac262169ef
commit 415c08f380
2 changed files with 28 additions and 1 deletions
+18 -1
View File
@@ -2,6 +2,23 @@
{% block title %}Dashboard{% endblock %}
{% block content %}
<script>
function confirmDelete(listingId) {
if (confirm("Are you sure you want to delete this listing?")) {
fetch(`/delete-listing/${listingId}`, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}).then(response => {
if (response.ok) {
window.location.reload();
}
});
}
}
</script>
<div class="container mt-4">
<h1 class="text-center">Host Dashboard</h1>
<div class="mt-4">
@@ -26,7 +43,7 @@
<td>{{ listing.property_type }}</td>
<td>
<a href="/edit-listing/{{ listing.id }}" class="btn btn-warning btn-sm">Edit</a>
<a href="/delete-listing/{{ listing.id }}" class="btn btn-danger btn-sm">Delete</a>
<button onclick="confirmDelete({{ listing.id }})" class="btn btn-danger btn-sm">Delete</button>
</td>
</tr>
{% endfor %}