1 Commits

Author SHA1 Message Date
ead941b395 Se agrega boton para mandar a procesar todos los pedimentos 2025-10-16 17:14:47 -05:00

View File

@@ -82,6 +82,9 @@ export default function Documents() {
const [selectedContributor, setSelectedContributor] = useState(''); const [selectedContributor, setSelectedContributor] = useState('');
const [loadingContributors, setLoadingContributors] = useState(false); const [loadingContributors, setLoadingContributors] = useState(false);
// Estado para agendar todo
const [isScheduling, setIsScheduling] = useState(false);
// Estado para controlar la animación de entrada // Estado para controlar la animación de entrada
const [showAnimation, setShowAnimation] = useState(false); const [showAnimation, setShowAnimation] = useState(false);
const [hasAnimated, setHasAnimated] = useState(false); const [hasAnimated, setHasAnimated] = useState(false);
@@ -508,6 +511,26 @@ export default function Documents() {
} }
}; };
// Función para agendar todo
const handleScheduleAll = async () => {
setIsScheduling(true);
try {
const endpoint = `${API_URL}/customs/auditor/procesar-pedimentos/organizaciones/`;
const result = await postWithAuth(endpoint, {});
showMessage('Pedimentos agendados exitosamente', 'success');
// Refrescar la lista después de agendar
refetch();
} catch (error) {
console.error('Error al agendar pedimentos:', error);
showMessage(`Error al agendar pedimentos: ${error.message}`, 'error');
} finally {
setIsScheduling(false);
}
};
// Actualizar isSelectAll cuando cambia la selección // Actualizar isSelectAll cuando cambia la selección
useEffect(() => { useEffect(() => {
if (currentDocuments.length > 0) { if (currentDocuments.length > 0) {
@@ -815,6 +838,23 @@ export default function Documents() {
</svg> </svg>
Agregar Expedientes Agregar Expedientes
</button> </button>
<button
onClick={handleScheduleAll}
disabled={isScheduling}
className="inline-flex items-center px-4 py-2.5 border border-transparent text-sm font-medium rounded-xl text-white bg-gradient-to-r from-blue-600 to-blue-700 hover:from-blue-700 hover:to-blue-800 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-all duration-200 transform hover:scale-105 shadow-lg disabled:opacity-50 disabled:cursor-not-allowed disabled:transform-none"
>
{isScheduling ? (
<svg className="w-4 h-4 mr-2 animate-spin" fill="none" viewBox="0 0 24 24">
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4"></circle>
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
) : (
<svg className="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" />
</svg>
)}
{isScheduling ? 'Agendando...' : 'Agendar Todo'}
</button>
<button <button
onClick={refetch} onClick={refetch}
disabled={loading} disabled={loading}