feat: add delete notification button with confirmation in admin notifications

This commit is contained in:
2026-06-14 10:03:59 -04:00
parent 6b2300de07
commit aea0a4d189
5 changed files with 56 additions and 1 deletions

View File

@@ -38,3 +38,23 @@ function sendNotification() {
btn.innerHTML = '<i class="fas fa-paper-plane"></i> Send';
});
}
function confirmDelete(id, title) {
if (!confirm('Delete notification "' + title + '"? This action cannot be undone.')) return;
const csrf = document.querySelector('meta[name="csrf-token"]')?.content || '';
fetch('/admin/notifications/' + id + '/delete', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'X-CSRF-Token': csrf,
},
body: '_csrf_token=' + encodeURIComponent(csrf),
})
.then(r => r.json())
.then(data => {
showToast(data.success ? 'success' : 'error', data.message);
if (data.success) location.reload();
})
.catch(() => showToast('error', 'Failed to delete notification'));
}