Fix didn't seem to work.

This commit is contained in:
Michael Woods
2025-12-26 14:50:52 -05:00
parent 30ecf63e29
commit 443da0523c

View File

@@ -22,7 +22,8 @@
</div> </div>
<div class="card-body"> <div class="card-body">
<p class="card-text">Once you delete a bulletin, there is no going back. Please be certain.</p> <p class="card-text">Once you delete a bulletin, there is no going back. Please be certain.</p>
<button type="button" class="btn btn-danger" onclick="deleteBulletin({{ bulletin.id }}, '{{ bulletin.subject | e }}')"> <button type="button" class="btn btn-danger"
onclick="deleteBulletin({{ bulletin.id }}, {{ bulletin.subject | tojson }})">
Delete This Bulletin Permanently Delete This Bulletin Permanently
</button> </button>
</div> </div>
@@ -30,13 +31,16 @@
<script> <script>
async function deleteBulletin(id, subject) { async function deleteBulletin(id, subject) {
console.log("Clicked delete!") console.log("Delete clicked for bulletin " + id);
if (!confirm(`Permanently delete bulletin "${subject}"? This cannot be undone.`)) return; if (!confirm(`Permanently delete bulletin "${subject}"? This cannot be undone.`)) {
return;
}
const response = await fetch(`/api/v1/bulletins/${id}`, { method: 'DELETE' }); const response = await fetch(`/api/v1/bulletins/${id}`, { method: 'DELETE' });
if (response.ok) { if (response.ok) {
window.location.href = '/bulletins'; window.location.href = '/bulletins';
} else { } else {
alert('Delete failed: ' + (await response.text() || 'Unknown error')); const errorText = await response.text();
alert('Delete failed: ' + (errorText || 'Unknown error'));
} }
} }
</script> </script>