nuevo dash

This commit is contained in:
kvilches1410
2026-03-31 16:57:26 -03:00
parent b4a0dfae24
commit 5467427a08
9 changed files with 820 additions and 732 deletions
+31
View File
@@ -0,0 +1,31 @@
/**
* js/api.js
* Centraliza la comunicación con el Backend (Vercel Serverless Function)
*/
export const api = {
data: null, // Guarda la última respuesta en memoria del cliente
/**
* Obtiene los datos de JIRA desde nuestro backend
* @param {boolean} forceRefresh - Forzar bypassing de la caché del backend
*/
async fetchDashboardData(forceRefresh = false, period = '90d') {
let url = `/api/data?period=${period}`;
if (forceRefresh) url += '&refresh=1';
try {
const res = await fetch(url);
if (!res.ok) {
const err = await res.json().catch(() => ({ error: `HTTP ${res.status}` }));
throw new Error(err.error || `HTTP ${res.status}`);
}
const json = await res.json();
this.data = json; // Guardar en memoria global de la app
return json;
} catch (e) {
console.error('Error al cargar datos:', e);
throw e;
}
}
};