Actualizar frontend/src/lib/api.js
This commit is contained in:
@@ -156,6 +156,22 @@ export const api = {
|
||||
method: "POST", headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ codigos, asesores, estados }),
|
||||
}).then((r) => { if (!r.ok) throw new Error("Error al obtener base"); return r.json(); }),
|
||||
// EXPORTAR BASE
|
||||
exportarBaseAsesores: () => _fetch("/api/exportar-base/asesores", {}),
|
||||
exportarBaseDescargar: async (asesor, etiquetas = []) => {
|
||||
const qEtq = (etiquetas || []).map((e) => `&etiquetas=${encodeURIComponent(e)}`).join("");
|
||||
const r = await fetch(`${BASE_URL}/api/exportar-base?asesor=${encodeURIComponent(asesor)}${qEtq}`);
|
||||
if (!r.ok) throw new Error("Error al exportar base");
|
||||
const blob = await r.blob();
|
||||
const cd = r.headers.get("Content-Disposition") || "";
|
||||
const m = cd.match(/filename=([^;]+)/);
|
||||
const nombre = m ? m[1].trim() : "base.xlsx";
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.href = url; a.download = nombre;
|
||||
document.body.appendChild(a); a.click();
|
||||
document.body.removeChild(a); URL.revokeObjectURL(url);
|
||||
},
|
||||
// SUBIR BASE
|
||||
subirBaseEtiquetas: () => _fetch("/api/subir-base/etiquetas", {}),
|
||||
subirBaseAsesores: () => _fetch("/api/subir-base/asesores", {}),
|
||||
|
||||
Reference in New Issue
Block a user