se modifico auditor y pagina de procesos
This commit is contained in:
@@ -1,31 +1,29 @@
|
||||
import { fetchWithAuth } from '../fetchWithAuth';
|
||||
|
||||
// Tipos para la respuesta y registros
|
||||
export interface ProcesamientoPedimento {
|
||||
id: number;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
export interface Task {
|
||||
task_id: string;
|
||||
timestamp: string;
|
||||
message: string;
|
||||
status: string;
|
||||
pedimento: string;
|
||||
organizacion: string;
|
||||
organizacion_name: string;
|
||||
estado: number;
|
||||
tipo_procesamiento: number;
|
||||
pedimento: string;
|
||||
servicio: number;
|
||||
}
|
||||
|
||||
export interface ProcesamientoPedimentosResponse {
|
||||
export interface TasksResponse {
|
||||
count: number;
|
||||
next: string | null;
|
||||
previous: string | null;
|
||||
results: ProcesamientoPedimento[];
|
||||
results: Task[];
|
||||
}
|
||||
|
||||
// API para customs/procesamientopedimentos/
|
||||
export async function fetchProcesamientoPedimentos(
|
||||
// API para tasks/tasks/
|
||||
export async function fetchTasks(
|
||||
page: number = 1,
|
||||
pageSize: number = 20,
|
||||
filters: Record<string, any> = {}
|
||||
): Promise<ProcesamientoPedimentosResponse> {
|
||||
): Promise<TasksResponse> {
|
||||
try {
|
||||
const API_URL = (import.meta as any).env.VITE_EFC_API_URL;
|
||||
|
||||
@@ -41,15 +39,15 @@ export async function fetchProcesamientoPedimentos(
|
||||
}
|
||||
});
|
||||
|
||||
const res = await fetchWithAuth(`${API_URL}/customs/procesamientopedimentos/?${params.toString()}`);
|
||||
const res = await fetchWithAuth(`${API_URL}/tasks/tasks/?${params.toString()}`);
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error('Error al obtener procesamiento de pedimentos');
|
||||
throw new Error('Error al obtener tareas');
|
||||
}
|
||||
|
||||
return await res.json();
|
||||
} catch (error) {
|
||||
console.error('Error in fetchProcesamientoPedimentos:', error);
|
||||
console.error('Error in fetchTasks:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
36
src/api/taskStatus.js
Normal file
36
src/api/taskStatus.js
Normal file
@@ -0,0 +1,36 @@
|
||||
// Helper functions for task status display
|
||||
|
||||
export const getTaskStatusLabel = (status) => {
|
||||
const statuses = {
|
||||
'submitted': 'Enviado',
|
||||
'pending': 'Pendiente',
|
||||
'processing': 'Procesando',
|
||||
'completed': 'Completado',
|
||||
'failed': 'Error',
|
||||
'cancelled': 'Cancelado'
|
||||
};
|
||||
return statuses[status] || `Estado ${status}`;
|
||||
};
|
||||
|
||||
export const getTaskStatusColor = (status) => {
|
||||
const colors = {
|
||||
'submitted': 'bg-blue-100 text-blue-800',
|
||||
'pending': 'bg-yellow-100 text-yellow-800',
|
||||
'processing': 'bg-indigo-100 text-indigo-800',
|
||||
'completed': 'bg-green-100 text-green-800',
|
||||
'failed': 'bg-red-100 text-red-800',
|
||||
'cancelled': 'bg-gray-100 text-gray-800'
|
||||
};
|
||||
return colors[status] || 'bg-gray-100 text-gray-800';
|
||||
};
|
||||
|
||||
// Ayuda a determinar si el estado permite ciertas acciones
|
||||
export const isTaskActionable = (status) => {
|
||||
const nonActionableStatuses = ['processing', 'completed', 'cancelled'];
|
||||
return !nonActionableStatuses.includes(status);
|
||||
};
|
||||
|
||||
export const isTaskFinal = (status) => {
|
||||
const finalStatuses = ['completed', 'failed', 'cancelled'];
|
||||
return finalStatuses.includes(status);
|
||||
};
|
||||
Reference in New Issue
Block a user