feature/rbac y perfiles implementados
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { fetchWithAuth } from '../fetchWithAuth';
|
||||
import { extractApiError } from '../api/apiError';
|
||||
|
||||
const API_URL = import.meta.env.VITE_EFC_API_URL;
|
||||
|
||||
@@ -13,7 +14,8 @@ export const downloadFile = async (id, filename = 'archivo', showMessage) => {
|
||||
const res = await fetchWithAuth(`${API_URL}/record/documents/descargar/${id}/`);
|
||||
|
||||
if (!res.ok) {
|
||||
showMessage('Error en la descarga del archivo', 'error');
|
||||
const errMsg = await extractApiError(res);
|
||||
showMessage(errMsg, 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -50,8 +52,11 @@ export const downloadBulkZip = async (ids, showMessage, pedimentoName) => {
|
||||
body: JSON.stringify({ document_ids: ids })
|
||||
});
|
||||
|
||||
if (!response.ok) throw new Error('Error en la descarga');
|
||||
|
||||
if (!response.ok) {
|
||||
const errMsg = await extractApiError(response);
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
|
||||
const blob = await response.blob();
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
|
||||
Reference in New Issue
Block a user