Implement PDF download functionality for membership applications; enhance application data handling in the API to support both encrypted and unencrypted formats. Update UI to display download button conditionally based on PDF generation status.

This commit is contained in:
Torsten Schulz (local)
2025-10-23 15:21:39 +02:00
parent d93312d03a
commit 9524a29b67
13 changed files with 207 additions and 26 deletions

View File

@@ -71,6 +71,16 @@
>
Anzeigen
</button>
<button
v-if="application.metadata.pdfGenerated"
@click="downloadPDF(application.id)"
class="px-3 py-1 text-sm bg-blue-100 hover:bg-blue-200 text-blue-700 rounded-lg transition-colors flex items-center"
>
<svg class="w-4 h-4 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
</svg>
PDF
</button>
<button
v-if="application.status === 'pending'"
@click="approveApplication(application.id)"
@@ -182,6 +192,16 @@
>
Schließen
</button>
<button
v-if="selectedApplication.metadata.pdfGenerated"
@click="downloadPDF(selectedApplication.id)"
class="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors flex items-center"
>
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
</svg>
PDF herunterladen
</button>
<button
v-if="selectedApplication.status === 'pending'"
@click="approveApplication(selectedApplication.id)"
@@ -268,6 +288,32 @@ const rejectApplication = async (id) => {
}
}
const downloadPDF = async (id) => {
try {
const filename = `beitrittserklärung_${id}.pdf`
// Direkter Download über die öffentliche Uploads-Route
const response = await fetch(`/uploads/${filename}`)
if (!response.ok) {
throw new Error('PDF nicht gefunden')
}
const blob = await response.blob()
const url = window.URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = filename
document.body.appendChild(a)
a.click()
window.URL.revokeObjectURL(url)
document.body.removeChild(a)
} catch (error) {
console.error('Fehler beim Herunterladen:', error)
alert('Fehler beim Herunterladen des PDFs')
}
}
const formatDate = (dateString) => {
return new Date(dateString).toLocaleDateString('de-DE', {
year: 'numeric',