Refactor error and confirmation handling in membership application management; replace alerts with modal dialogs for improved user experience. Update application status to 'approved' for a new member and add corresponding data to JSON files.

This commit is contained in:
Torsten Schulz (local)
2025-10-23 15:32:20 +02:00
parent 9524a29b67
commit 6763b15487
13 changed files with 321 additions and 101 deletions

View File

@@ -238,7 +238,7 @@ const loadApplications = async () => {
applications.value = response
} catch (error) {
console.error('Fehler beim Laden der Anträge:', error)
alert('Fehler beim Laden der Anträge')
window.showErrorModal('Fehler', 'Fehler beim Laden der Anträge')
} finally {
loading.value = false
}
@@ -257,35 +257,35 @@ const closeModal = () => {
}
const approveApplication = async (id) => {
if (confirm('Antrag genehmigen?')) {
window.showConfirmModal('Bestätigung erforderlich', 'Möchten Sie diesen Antrag wirklich genehmigen?', async () => {
try {
await $fetch('/api/membership/update-status', {
method: 'PUT',
body: { id, status: 'approved' }
})
await loadApplications()
alert('Antrag wurde genehmigt')
window.showSuccessModal('Erfolg', 'Antrag wurde erfolgreich genehmigt')
} catch (error) {
console.error('Fehler beim Genehmigen:', error)
alert('Fehler beim Genehmigen des Antrags')
window.showErrorModal('Fehler', 'Fehler beim Genehmigen des Antrags')
}
}
})
}
const rejectApplication = async (id) => {
if (confirm('Antrag ablehnen?')) {
window.showConfirmModal('Bestätigung erforderlich', 'Möchten Sie diesen Antrag wirklich ablehnen?', async () => {
try {
await $fetch('/api/membership/update-status', {
method: 'PUT',
body: { id, status: 'rejected' }
})
await loadApplications()
alert('Antrag wurde abgelehnt')
window.showSuccessModal('Erfolg', 'Antrag wurde erfolgreich abgelehnt')
} catch (error) {
console.error('Fehler beim Ablehnen:', error)
alert('Fehler beim Ablehnen des Antrags')
window.showErrorModal('Fehler', 'Fehler beim Ablehnen des Antrags')
}
}
})
}
const downloadPDF = async (id) => {
@@ -308,9 +308,11 @@ const downloadPDF = async (id) => {
a.click()
window.URL.revokeObjectURL(url)
document.body.removeChild(a)
window.showSuccessModal('Erfolg', 'PDF wurde erfolgreich heruntergeladen')
} catch (error) {
console.error('Fehler beim Herunterladen:', error)
alert('Fehler beim Herunterladen des PDFs')
window.showErrorModal('Fehler', 'Fehler beim Herunterladen des PDFs')
}
}