diff --git a/resources/views/vcard_api.html b/resources/views/vcard_api.html index 65289ed..8e1281d 100644 --- a/resources/views/vcard_api.html +++ b/resources/views/vcard_api.html @@ -1581,6 +1581,7 @@ function vcardApiApp() { sortByVenc: false, loadingVenc: false, filterPlan: '', + knownPlans: [], // planes acumulados de todas las páginas cargadas membresiaMap: {}, // { userId: { fecha_fin, activo, plan } } // Desactivar usuario + VCards @@ -1748,6 +1749,8 @@ function vcardApiApp() { this.items = []; this.total = 0; this.errorMsg = ''; + this.filterPlan = ''; + this.knownPlans = []; if (this.hasConfig) this.loadTab(); }, @@ -1787,11 +1790,11 @@ function vcardApiApp() { if (d.data && Array.isArray(d.data)) { this.items = d.data; this.total = d.total || d.data.length; - if (this.tab === 'usuarios') this._collectRoles(d.data); + if (this.tab === 'usuarios') { this._collectRoles(d.data); this._collectPlanes(d.data); } } else if (Array.isArray(d)) { this.items = d; this.total = d.length; - if (this.tab === 'usuarios') this._collectRoles(d); + if (this.tab === 'usuarios') { this._collectRoles(d); this._collectPlanes(d); } } else { this.items = []; this.total = 0; @@ -1816,6 +1819,16 @@ function vcardApiApp() { }); }, + _collectPlanes(users) { + users.forEach(u => { + const nombre = (u.plan && u.plan.nombre) ? u.plan.nombre : ''; + if (nombre && !this.knownPlans.includes(nombre)) { + this.knownPlans.push(nombre); + this.knownPlans.sort(); + } + }); + }, + // ─── Ordenar por vencimiento ───────────────────────────────────────── diasHastaVencer(u) { @@ -1906,8 +1919,7 @@ function vcardApiApp() { }, planesDisponibles() { - const nombres = [...new Set(this.items.map(u => (u.plan && u.plan.nombre) || ''))].filter(Boolean).sort(); - return nombres; + return this.knownPlans; }, usuariosFiltrados() {