diff --git a/src/api/edocuments.js b/src/api/edocuments.js index 8cf56fb..d19f1a6 100644 --- a/src/api/edocuments.js +++ b/src/api/edocuments.js @@ -56,3 +56,12 @@ export const downloadAcuseEdocument = async (edocId) => { window.URL.revokeObjectURL(url); document.body.removeChild(a); }; + +export const resetAcuseEdocument = async (edocId) => { + const response = await fetchWithAuth( + `${API_BASE_URL}/customs/edocuments/${edocId}/reset-acuse/`, + { method: 'POST' } + ); + if (!response.ok) throw new Error(await extractApiError(response)); + return response.json(); +}; diff --git a/src/pages/Auditor.jsx b/src/pages/Auditor.jsx index 08d52d7..de30586 100644 --- a/src/pages/Auditor.jsx +++ b/src/pages/Auditor.jsx @@ -1,5 +1,5 @@ -import React, { useState, useEffect } from 'react'; +import React, { useState, useEffect, useRef } from 'react'; import { Link } from 'react-router-dom'; import { getWithAuth, postWithAuth, fetchWithAuth } from '../fetchWithAuth'; import { useNotification } from '../context/NotificationContext'; @@ -34,15 +34,43 @@ const PROCESAMIENTO_URL_MAP = { function AuditResultModal({ modal, iniciandoProcesamiento, onClose, onIniciarProcesamiento }) { const { tipo, pedimento_app, data } = modal; - // si el backend no retorna 'estado' (ej. pedimento completo), tratamos como no completado - const esCompletado = data?.estado === 'completado' || data?.auditoria_completa == true; - // remesa sin remesas: no tiene nada que procesar, ocultar botón - const sinNadaQueHacer = tipo === 'rm' && data?.tiene_remesas === false; + + const esCompletado = tipo === 'pc' + ? (!data?.hay_pendientes && !data?.hay_errores) + : (data?.estado === 'completado' || data?.auditoria_completa == true); + + const sinNadaQueHacer = (tipo === 'rm' && data?.tiene_remesas === false); const mostrarBotonProcesar = !esCompletado && !sinNadaQueHacer; - const tituloTipo = TIPO_LABELS[tipo] || tipo; + const hayErroresPC = tipo === 'pc' && data?.hay_errores; - const iconoEstado = esCompletado ? ( + const headerBg = hayErroresPC + ? 'bg-red-50 border-b border-red-100' + : esCompletado + ? 'bg-green-50 border-b border-green-100' + : 'bg-amber-50 border-b border-amber-100'; + + const badge = hayErroresPC ? ( + + Con errores + + ) : esCompletado ? ( + + Completado + + ) : ( + + Pendiente + + ); + + const iconoEstado = hayErroresPC ? ( +
{tituloTipo}
{data?.mensaje}
- - {/* Resumen numérico */} - {data?.resumen && ( -Información del pedimento