feat: Add PDF export button to reports dashboard - v1.0.14
This commit is contained in:
@@ -38,7 +38,7 @@ services:
|
||||
command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 4
|
||||
|
||||
frontend:
|
||||
image: dymai/syntria-frontend:latest
|
||||
image: dymai/syntria-frontend:1.0.14
|
||||
container_name: syntria-frontend-prod
|
||||
restart: always
|
||||
depends_on:
|
||||
|
||||
@@ -3472,6 +3472,7 @@ function ReportsTab({ user }) {
|
||||
<th className="text-right py-2 px-4">Score</th>
|
||||
<th className="text-center py-2 px-4">Estado</th>
|
||||
<th className="text-center py-2 px-4">Alertas</th>
|
||||
<th className="text-center py-2 px-4">Acciones</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -3500,6 +3501,40 @@ function ReportsTab({ user }) {
|
||||
</span>
|
||||
)}
|
||||
</td>
|
||||
<td className="py-2 px-4 text-center">
|
||||
<button
|
||||
onClick={async () => {
|
||||
try {
|
||||
const token = localStorage.getItem('token')
|
||||
const API_URL = import.meta.env.VITE_API_URL || ''
|
||||
const response = await fetch(`${API_URL}/api/inspections/${inspection.id}/pdf`, {
|
||||
headers: { 'Authorization': `Bearer ${token}` }
|
||||
})
|
||||
|
||||
if (response.ok) {
|
||||
const blob = await response.blob()
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
const a = document.createElement('a')
|
||||
a.href = url
|
||||
a.download = `inspeccion_${inspection.id}_${inspection.vehicle_plate || 'sin-patente'}.pdf`
|
||||
document.body.appendChild(a)
|
||||
a.click()
|
||||
document.body.removeChild(a)
|
||||
window.URL.revokeObjectURL(url)
|
||||
} else {
|
||||
alert('Error al generar PDF')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error:', error)
|
||||
alert('Error al generar PDF')
|
||||
}
|
||||
}}
|
||||
className="px-3 py-1 bg-indigo-600 text-white rounded hover:bg-indigo-700 transition"
|
||||
title="Exportar PDF"
|
||||
>
|
||||
📄
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
|
||||
Reference in New Issue
Block a user