Actualizar proveedores.html
This commit is contained in:
@@ -246,12 +246,13 @@
|
||||
|
||||
function startPolling() {
|
||||
if (pollingInterval) clearInterval(pollingInterval);
|
||||
// Reduce el tiempo a 5 segundos para que parezca instantáneo
|
||||
pollingInterval = setInterval(async () => {
|
||||
const modal = document.getElementById('importModal');
|
||||
if (modal.classList.contains('hidden')) {
|
||||
await loadInbox();
|
||||
}
|
||||
}, 30000);
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
async function loadGuilds() {
|
||||
@@ -280,29 +281,36 @@
|
||||
try {
|
||||
const resSvc = await fetch(`${API_URL}/providers/scraped`, { headers: { "Authorization": `Bearer ${localStorage.getItem("token")}` } });
|
||||
const dataSvc = await resSvc.json();
|
||||
scrapedData = dataSvc.services || [];
|
||||
|
||||
const compSelect = document.getElementById('filterCompany');
|
||||
const currentVal = compSelect.value;
|
||||
const uniqueCompanies = [...new Set(scrapedData.map(s => {
|
||||
const raw = s.raw_data || {};
|
||||
return (raw['Compañía'] || raw['COMPAÑIA'] || raw['Procedencia'] || "S/C").toString().toUpperCase().trim();
|
||||
}))].sort();
|
||||
|
||||
compSelect.innerHTML = '<option value="ALL">COMPAÑÍAS</option>';
|
||||
uniqueCompanies.forEach(c => compSelect.innerHTML += `<option value="${c}">${c}</option>`);
|
||||
compSelect.value = currentVal;
|
||||
|
||||
const active = scrapedData.filter(s => s.status === 'pending').length;
|
||||
const archived = scrapedData.filter(s => s.status === 'archived').length;
|
||||
document.getElementById('countActive').innerText = active;
|
||||
document.getElementById('countArchived').innerText = archived;
|
||||
document.getElementById('countTotal').innerText = scrapedData.length;
|
||||
|
||||
renderFilteredInbox();
|
||||
// Verificamos si ha habido cambios para no renderizar a lo loco
|
||||
if (JSON.stringify(scrapedData) !== JSON.stringify(dataSvc.services)) {
|
||||
scrapedData = dataSvc.services || [];
|
||||
updateFiltersAndRender();
|
||||
}
|
||||
} catch (e) { console.error("Error en loadInbox:", e); }
|
||||
}
|
||||
|
||||
function updateFiltersAndRender() {
|
||||
const compSelect = document.getElementById('filterCompany');
|
||||
const currentVal = compSelect.value;
|
||||
const uniqueCompanies = [...new Set(scrapedData.map(s => {
|
||||
const raw = s.raw_data || {};
|
||||
return (raw['Compañía'] || raw['COMPAÑIA'] || raw['Procedencia'] || "S/C").toString().toUpperCase().trim();
|
||||
}))].sort();
|
||||
|
||||
compSelect.innerHTML = '<option value="ALL">COMPAÑÍAS</option>';
|
||||
uniqueCompanies.forEach(c => compSelect.innerHTML += `<option value="${c}">${c}</option>`);
|
||||
compSelect.value = currentVal;
|
||||
|
||||
const active = scrapedData.filter(s => s.status === 'pending').length;
|
||||
const archived = scrapedData.filter(s => s.status === 'archived').length;
|
||||
document.getElementById('countActive').innerText = active;
|
||||
document.getElementById('countArchived').innerText = archived;
|
||||
document.getElementById('countTotal').innerText = scrapedData.length;
|
||||
|
||||
renderFilteredInbox();
|
||||
}
|
||||
|
||||
function buildServiceCard(svc) {
|
||||
const raw = svc.raw_data || {};
|
||||
const isArchived = svc.status === 'archived';
|
||||
@@ -313,7 +321,6 @@
|
||||
const fullAddr = `${addr} ${pop}`.trim();
|
||||
const phone = (raw['Teléfono'] || raw['TELEFONOS'] || raw['TELEFONO'] || "").match(/[6789]\d{8}/)?.[0] || "";
|
||||
|
||||
// CORRECCIÓN BLINDADA DEL GREMIO
|
||||
let guildName = null;
|
||||
const rawGuildId = svc.guild_id || raw['guild_id'] || raw.guild_id;
|
||||
|
||||
@@ -381,7 +388,7 @@
|
||||
<span class="text-[8px] font-bold text-red-400">Nadie aceptó</span>
|
||||
</div>`;
|
||||
} else {
|
||||
bgClass = isUrgent ? 'bg-red-50/20 border-red-300 hover:border-red-500 shadow-[0_0_15px_rgba(239,68,68,0.15)]' : 'bg-white border-slate-200';
|
||||
bgClass = isUrgent ? 'bg-red-50/20 border-red-300 hover:border-red-50 shadow-[0_0_15px_rgba(239,68,68,0.15)]' : 'bg-white border-slate-200';
|
||||
badgeEstado = `
|
||||
<div class="flex flex-col items-end gap-1">
|
||||
<span class="bg-slate-100 text-slate-500 px-3 py-1 rounded-full text-[10px] font-black uppercase flex items-center gap-1.5 border border-slate-200">
|
||||
|
||||
Reference in New Issue
Block a user