fix: parsear d.data[] de la API de notas (no d.clinica/d.libres inexistentes)

This commit is contained in:
Lizandro Guarnizo
2026-03-25 14:21:17 -05:00
parent 921c6abd8c
commit 7917f4852e
2 changed files with 11 additions and 6 deletions
+5 -2
View File
@@ -1641,11 +1641,14 @@ const notasManager = {
async _cargar(domId) {
const r = await fetch(`api/lab/get_notas_domicilio.php?domicilio_id=${domId}`);
const d = await r.json();
const notas = d.success ? (d.data || []) : [];
const clinica = notas.find(n => n.tipo === 'clinica') || null;
const libres = notas.filter(n => n.tipo === 'libre');
this._cache[domId] = d.success
? { clinica: d.clinica || null, libres: d.libres || [] }
? { clinica, libres }
: { clinica: null, libres: [] };
// Actualizar badge
const total = (d.libres || []).length + (d.clinica ? 1 : 0);
const total = libres.length + (clinica ? 1 : 0);
const badge = document.getElementById(`nota-count-${domId}`);
if (badge) {
badge.textContent = total;