Se soluciono autenticacion

This commit is contained in:
2025-08-05 13:06:24 -06:00
parent c280afe646
commit c9df4e3ab2
21 changed files with 758 additions and 624 deletions

View File

@@ -1,4 +1,5 @@
// src/api/pedimentoDocuments.ts
import { fetchWithAuth } from '../fetchWithAuth';
export interface PedimentoDocument {
id: string;
@@ -23,8 +24,6 @@ export interface PedimentoDocumentsResponse {
const API_URL = import.meta.env.VITE_EFC_API_URL;
export async function fetchPedimentoDocuments(
token: string,
pedimentoId: string = '',
page: number = 1,
pageSize: number = 10,
filters: {
@@ -32,7 +31,8 @@ export async function fetchPedimentoDocuments(
extension?: string;
document_type?: string | number;
created_at?: string;
} = {}
} = {},
pedimentoId: string = ''
): Promise<PedimentoDocumentsResponse> {
const params = new URLSearchParams();
params.append('page', String(page));
@@ -43,18 +43,10 @@ export async function fetchPedimentoDocuments(
if (filters.document_type) params.append('document_type', String(filters.document_type));
if (filters.created_at) params.append('created_at', filters.created_at);
const res = await fetch(
`${API_URL}/record/documents/?${params.toString()}`,
{
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json',
},
}
const res = await fetchWithAuth(
`${API_URL}/record/documents/?${params.toString()}`
);
if (res.status === 401) {
throw new Error('SESSION_EXPIRED');
}
if (!res.ok) throw new Error('No autorizado o error en la petición');
return res.json();
}