From 7b44ee8767dca0d140e7f3db928349ec24f2f4fc Mon Sep 17 00:00:00 2001 From: marsalva Date: Sun, 15 Feb 2026 16:53:05 +0000 Subject: [PATCH] Actualizar usuarios.html --- usuarios.html | 64 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 19 deletions(-) diff --git a/usuarios.html b/usuarios.html index 5604e70..0d2dc94 100644 --- a/usuarios.html +++ b/usuarios.html @@ -404,25 +404,51 @@ }); } - function renderUsersTable() { - const tbody = document.getElementById('usersListBody'); - tbody.innerHTML = currentUsers.length === 0 ? `Cargando equipo...` : ""; - currentUsers.forEach(u => { - const uGuildNames = (u.guilds || []).map(gid => availableGuilds.find(ag => ag.id === gid)?.name).filter(Boolean).join(", "); - const uZonesHtml = (u.zones || []).map(z => `📍 ${z.city}: ${z.cps}`).join(""); - tbody.innerHTML += ` - -
${u.full_name}${u.email}
- ${u.phone} - ${u.role}

${uGuildNames || '-'}

- ${uZonesHtml || 'Sin zona'} - - - - - `; - }); - } + function renderUsersTable() { + const tbody = document.getElementById('usersListBody'); + tbody.innerHTML = currentUsers.length === 0 ? `Cargando equipo...` : ""; + + currentUsers.forEach(u => { + const uGuildNames = (u.guilds || []).map(gid => availableGuilds.find(ag => ag.id === gid)?.name).filter(Boolean).join(", "); + + // --- LÓGICA DE AGRUPACIÓN POR MUNICIPIO --- + const groupedZones = (u.zones || []).reduce((acc, current) => { + if (!acc[current.city]) { + acc[current.city] = []; + } + // Evitamos duplicados de CP en la misma ciudad + if (!acc[current.city].includes(current.cps)) { + acc[current.city].push(current.cps); + } + return acc; + }, {}); + + // Convertimos el objeto agrupado en HTML elegante + const uZonesHtml = Object.keys(groupedZones).map(city => { + const cps = groupedZones[city].join(", "); + return `
+ 📍 ${city} + (${cps}) +
`; + }).join("") || 'Sin zona'; + + tbody.innerHTML += ` + +
${u.full_name}${u.email}
+ ${u.phone} + ${u.role}

${uGuildNames || '-'}

+ +
+ ${uZonesHtml} +
+ + + + + + `; + }); +} function showToast(msg, err=false){ const t=document.getElementById('toast'), m=document.getElementById('toastMsg');