feature/rbac y perfiles implementados
This commit is contained in:
@@ -1,44 +1,42 @@
|
||||
// Consultar el estado de un task por task_id
|
||||
import { getWithAuth, postWithAuth, patchWithAuth, deleteWithAuth } from '../fetchWithAuth';
|
||||
import { extractApiError } from './apiError';
|
||||
|
||||
const API_BASE = `${import.meta.env.VITE_EFC_API_URL}/datastage/datastages/`;
|
||||
|
||||
export async function fetchTaskStatus(task_id) {
|
||||
const url = `${import.meta.env.VITE_EFC_API_URL}/datastage/datastages/task-status/?task_id=${encodeURIComponent(task_id)}`;
|
||||
const res = await getWithAuth(url);
|
||||
if (!res.ok) throw new Error('Error al consultar el estado del task');
|
||||
if (!res.ok) throw new Error(await extractApiError(res));
|
||||
return res.json();
|
||||
}
|
||||
|
||||
import.meta.env;
|
||||
import { getWithAuth, postWithAuth, patchWithAuth, deleteWithAuth } from '../fetchWithAuth';
|
||||
const API_BASE = `${import.meta.env.VITE_EFC_API_URL}/datastage/datastages/`;
|
||||
|
||||
export async function fetchDatastages(page = 1, page_size = 10) {
|
||||
const url = `${API_BASE}?page=${page}&page_size=${page_size}`;
|
||||
const res = await getWithAuth(url);
|
||||
if (!res.ok) throw new Error('Error al obtener datastages');
|
||||
const data = await res.json();
|
||||
// Si la respuesta es paginada, devolver el objeto completo
|
||||
return data;
|
||||
if (!res.ok) throw new Error(await extractApiError(res));
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function fetchDatastageDetail(id) {
|
||||
const res = await getWithAuth(`${API_BASE}${id}/`);
|
||||
if (!res.ok) throw new Error('Error al obtener detalle');
|
||||
if (!res.ok) throw new Error(await extractApiError(res));
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function createDatastage(data) {
|
||||
const res = await postWithAuth(API_BASE, data);
|
||||
if (!res.ok) throw new Error('Error al crear datastage');
|
||||
if (!res.ok) throw new Error(await extractApiError(res));
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function updateDatastage(id, data) {
|
||||
const res = await patchWithAuth(`${API_BASE}${id}/`, data);
|
||||
if (!res.ok) throw new Error('Error al actualizar datastage');
|
||||
if (!res.ok) throw new Error(await extractApiError(res));
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function deleteDatastage(id) {
|
||||
const res = await deleteWithAuth(`${API_BASE}${id}/`);
|
||||
if (!res.ok) throw new Error('Error al eliminar datastage');
|
||||
if (!res.ok) throw new Error(await extractApiError(res));
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user