diff --git a/web-v2/src/pages/ReportsPage.tsx b/web-v2/src/pages/ReportsPage.tsx index 4a1f156..ffc90e2 100644 --- a/web-v2/src/pages/ReportsPage.tsx +++ b/web-v2/src/pages/ReportsPage.tsx @@ -6,8 +6,15 @@ import { Icon } from '../components/Icon'; import { useOperationalContext } from '../context/OperationalContext'; import { DocumentCenterTabs } from '../features/documents/DocumentCenterTabs'; import { OperationalFilters } from '../features/inspections/OperationalFilters'; -import { listInspectionReports, listPendingInspectionReports } from '../lib/api'; -import type { InspectionReportListItem, PageMeta, PendingInspectionReportItem } from '../lib/api'; +import { + listInspectionReportsF4, + listPendingInspectionReportsF4, +} from '../lib/reportWorkflowApi'; +import type { + InspectionReportDetailF4, + PageMetaF4, + PendingInspectionReportF4, +} from '../lib/reportWorkflowApi'; import { formatDate } from '../lib/format'; function contextLabel(items: Array<{ name: string }>, empty: string): string { @@ -18,16 +25,16 @@ function contextLabel(items: Array<{ name: string }>, empty: string): string { return `${first.name} +${items.length - 1}`; } - -function reviewLabel(value: InspectionReportListItem['reviewStatus']): string { - if (value === 'SIGNED') return 'Firmado'; - if (value === 'APPROVED') return 'Aprobado'; - return 'Pendiente'; +function statusLabel(report: InspectionReportDetailF4): string { + if (report.status === 'OFFICIALIZED') return report.gedoIfIdentifier ? `GEDO · ${report.gedoIfIdentifier}` : 'Oficializado en GEDO'; + if (report.status === 'WORKING') return 'En preparación'; + if (report.status === 'CANCELLED') return 'Cancelado'; + return 'Legado congelado'; } -function reviewClass(value: InspectionReportListItem['reviewStatus']): string { - if (value === 'SIGNED') return 'active'; - if (value === 'APPROVED') return 'observed'; +function statusClass(report: InspectionReportDetailF4): string { + if (report.status === 'OFFICIALIZED') return 'active'; + if (report.status === 'CANCELLED') return 'danger'; return 'pending'; } @@ -44,9 +51,9 @@ export function ReportsPage() { const dateTo = params.get('dateTo') ?? ''; const page = Math.max(1, Number(params.get('page') ?? 1) || 1); const [draftSearch, setDraftSearch] = useState(search); - const [issued, setIssued] = useState([]); - const [pending, setPending] = useState([]); - const [meta, setMeta] = useState({ page: 1, pageSize: 25, total: 0, totalPages: 0 }); + const [issued, setIssued] = useState([]); + const [pending, setPending] = useState([]); + const [meta, setMeta] = useState({ page: 1, pageSize: 25, total: 0, totalPages: 0 }); const [loading, setLoading] = useState(true); const [error, setError] = useState(''); @@ -54,16 +61,27 @@ export function ReportsPage() { let cancelled = false; setLoading(true); setError(''); + const query = { + page, + pageSize: 25, + search, + year: year ? Number(year) : undefined, + companyId, + areaId, + inspectorId, + dateFrom, + dateTo, + }; const load = async () => { try { if (view === 'issued') { - const response = await listInspectionReports({ page, pageSize: 25, search, year: year ? Number(year) : '', companyId, areaId, inspectorId, dateFrom, dateTo }); + const response = await listInspectionReportsF4(query); if (cancelled) return; setIssued(response.data); setPending([]); setMeta(response.meta); } else { - const response = await listPendingInspectionReports({ page, pageSize: 25, search, year: year ? Number(year) : '', companyId, areaId, inspectorId, dateFrom, dateTo }); + const response = await listPendingInspectionReportsF4(query); if (cancelled) return; setPending(response.data); setIssued([]); @@ -110,39 +128,39 @@ export function ReportsPage() { return
-
CENTRO DOCUMENTAL

Informes

Registro global de informes de inspección generados automáticamente al cerrar cada visita.

+
CENTRO DOCUMENTAL

Informes

Cada Acta sellada genera un único INF editable. Luego el IF y PDF oficial de GEDO completan su trazabilidad institucional.

- - + +
- + - {view === 'pending' &&

Recuperación documental. Las actas históricas sin informe aparecen aquí. Desde D5.3.20 el informe se numera y congela automáticamente al cerrar la visita.

} + {view === 'pending' &&

Actas listas para generar INF. Esta bandeja sólo muestra Actas selladas que todavía no tienen su Informe 1 a 1.

} {error && {error}} - {loading ? : empty ? :
-
{meta.total} {view === 'issued' ? `informe${meta.total === 1 ? '' : 's'}` : `pendiente${meta.total === 1 ? '' : 's'}`}Página {page} de {Math.max(meta.totalPages, 1)}
-
{view === 'issued' ? : }{view === 'issued' ? issued.map((report) => + {loading ? : empty ? :
+
{meta.total} {view === 'issued' ? `informe${meta.total === 1 ? '' : 's'}` : `acta${meta.total === 1 ? '' : 's'} pendiente${meta.total === 1 ? '' : 's'}`}Página {page} de {Math.max(meta.totalPages, 1)}
+
InformeEmpresa / áreaActaHallazgosWordRevisión
Acta cerradaEmpresa / áreaInspecciónHallazgosCierre
{view === 'issued' ? : }{view === 'issued' ? issued.map((report) => - - + + ) : pending.map((item) => - + - + )}
InformeEmpresa / áreaActaHallazgosWordEstado
Acta selladaEmpresa / áreaInspecciónHallazgosSellado
{report.code}{report.title} · {formatDate(report.generatedAt)}
{contextLabel(report.companies, 'Empresa sin asignar')}{contextLabel(report.areas, 'Área sin asignar')}
{report.act.code}{report.act.title} {report.findingCount}{report.wordStatus === 'READY' ? 'Word disponible' : report.wordStatus === 'FAILED' ? 'Word con error' : 'Word pendiente'}{reviewLabel(report.reviewStatus)}{report.wordStatus === 'READY' ? 'Disponible' : report.wordStatus === 'FAILED' ? 'Error' : 'Pendiente'}{statusLabel(report)}
{item.actCode}{item.actTitle} · {formatDate(item.occurredAt)}
{contextLabel(item.companies, 'Empresa sin asignar')}{contextLabel(item.areas, 'Área sin asignar')}
{item.visitCode}{item.visitCode}{item.visitTitle} {item.findingCount}{formatDate(item.closedAt)}{formatDate(item.sealedAt)}
{meta.total ? `${(page - 1) * meta.pageSize + 1}–${Math.min(page * meta.pageSize, meta.total)} de ${meta.total}` : '0 resultados'}