Visualizzazione ricevute

This commit is contained in:
2026-03-25 18:02:50 +01:00
parent 03be5d0e32
commit f5fb537fed
4 changed files with 225 additions and 5 deletions
+20
View File
@@ -104,4 +104,24 @@ export const messagesApi = {
getReceipts: (id: string) =>
apiClient.get<MessageResponse[]>(`/messages/${id}/receipts`).then((r) => r.data),
/**
* Scarica il pacchetto ZIP completo della PEC (postacert.eml, daticert.xml,
* ricevute di accettazione/consegna per le mail outbound).
*/
downloadPackage: async (messageId: string, subject?: string | null): Promise<void> => {
const response = await apiClient.get(
`/messages/${messageId}/download-package`,
{ responseType: 'blob' },
)
const blobUrl = window.URL.createObjectURL(new Blob([response.data], { type: 'application/zip' }))
const anchor = document.createElement('a')
anchor.href = blobUrl
const safeSubject = (subject || 'pec').replace(/[/\\]/g, '_').slice(0, 50)
anchor.setAttribute('download', `pec_${safeSubject}.zip`)
document.body.appendChild(anchor)
anchor.click()
anchor.remove()
window.URL.revokeObjectURL(blobUrl)
},
}