From c30abb58a6cf78d9928fd43dd96f80b5522b87b3 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Mon, 25 May 2026 15:47:18 -0500 Subject: [PATCH] Update vcard_api.html --- resources/views/vcard_api.html | 47 +++++++++++++++++----------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/resources/views/vcard_api.html b/resources/views/vcard_api.html index bf0cca1..1cdfbed 100644 --- a/resources/views/vcard_api.html +++ b/resources/views/vcard_api.html @@ -140,8 +140,8 @@ @@ -1222,7 +1222,7 @@
-

Desactivar usuario + VCards

+

Inactivar VCards del usuario

@@ -1255,9 +1255,9 @@
- Este usuario no tiene VCards. Solo se desactivará la cuenta. + Este usuario no tiene VCards activas para inactivar.
-

¿Confirmas desactivar la cuenta del usuario y todas sus VCards?

+

¿Confirmas inactivar todas las VCards de este usuario? El usuario permanecerá activo.

@@ -1266,11 +1266,11 @@
@@ -1584,7 +1584,7 @@ function vcardApiApp() { knownPlans: [], // planes acumulados de todas las páginas cargadas membresiaMap: {}, // { userId: { fecha_fin, activo, plan } } - // Desactivar usuario + VCards + // Inactivar VCards del usuario (sin desactivar usuario) desactivarVcardsModal: false, desactivarVcardsUser: null, desactivarVcardsItems: [], @@ -1592,6 +1592,9 @@ function vcardApiApp() { desactivarVcardsError: '', desactivarVcardsResult: '', + // Cache acumulado de usuarios de todas las páginas (para filtro de planes) + allUsersCache: {}, + // Filtros por tab filters: { pagos: { estado: '', moneda: '', desde: '', hasta: '' }, @@ -1751,6 +1754,7 @@ function vcardApiApp() { this.errorMsg = ''; this.filterPlan = ''; this.knownPlans = []; + this.allUsersCache = {}; if (this.hasConfig) this.loadTab(); }, @@ -1821,6 +1825,9 @@ function vcardApiApp() { _collectPlanes(users) { users.forEach(u => { + // Acumular en cache para filtrado cross-página + const uid = u.id || u._id; + if (uid) this.allUsersCache[uid] = u; const nombre = (u.plan && u.plan.nombre) ? u.plan.nombre : ''; if (nombre && !this.knownPlans.includes(nombre)) { this.knownPlans.push(nombre); @@ -1924,7 +1931,9 @@ function vcardApiApp() { usuariosFiltrados() { if (!this.filterPlan) return this.items; - return this.items.filter(u => ((u.plan && u.plan.nombre) || '') === this.filterPlan); + // Filtrar desde el cache acumulado de TODAS las páginas cargadas + return Object.values(this.allUsersCache) + .filter(u => ((u.plan && u.plan.nombre) || '') === this.filterPlan); }, // ─── Planes ────────────────────────────────────────────────────────── @@ -2033,9 +2042,8 @@ function vcardApiApp() { this.desactivarVcardsError = ''; this.desactivarVcardsResult = ''; this.saving = true; - const id = this.desactivarVcardsUser.id || this.desactivarVcardsUser._id; try { - // 1. Inactivar cada VCard activa + // Solo inactivar cada VCard activa — no se toca al usuario let inactivadas = 0; const vcards = this.desactivarVcardsItems.filter(v => v.estado === true || v.estado === 1); for (const v of vcards) { @@ -2047,18 +2055,11 @@ function vcardApiApp() { }); if (r.ok) inactivadas++; } - // 2. Desactivar usuario - const rU = await fetch(`/app/vcard-api/usuarios/${id}/desactivar`, { method: 'POST' }); - const dU = await rU.json(); - if (!rU.ok) { - this.desactivarVcardsError = dU.error || 'Error al desactivar el usuario.'; - } else { - this.desactivarVcardsResult = `Usuario desactivado. VCards inactivadas: ${inactivadas} de ${vcards.length}.`; - setTimeout(async () => { - this.desactivarVcardsModal = false; - await this.loadTab(); - }, 1800); - } + this.desactivarVcardsResult = `VCards inactivadas: ${inactivadas} de ${vcards.length}. El usuario sigue activo.`; + setTimeout(async () => { + this.desactivarVcardsModal = false; + await this.loadTab(); + }, 1800); } catch(e) { this.desactivarVcardsError = e.message; } this.saving = false; },