feature/rbac y perfiles implementados

This commit is contained in:
2026-05-21 08:00:43 -06:00
parent 546a411df8
commit dc5f9fd6ce
29 changed files with 2007 additions and 977 deletions

19
src/api/apiError.js Normal file
View File

@@ -0,0 +1,19 @@
/**
* Extrae el mensaje de error de una respuesta HTTP fallida.
* Lee el JSON del body y devuelve `detail`, `message` o `error` del backend.
* Si no hay JSON, devuelve el texto o un fallback genérico con el status.
*/
export async function extractApiError(response) {
const status = response.status;
try {
const contentType = response.headers.get('content-type') || '';
if (contentType.includes('application/json')) {
const body = await response.json();
return body.detail || body.message || body.error || `Error ${status}`;
}
const text = await response.text();
return text || `Error ${status}`;
} catch {
return `Error ${status}`;
}
}