Actualizar proveedores.html
This commit is contained in:
@@ -246,12 +246,13 @@
|
|||||||
|
|
||||||
function startPolling() {
|
function startPolling() {
|
||||||
if (pollingInterval) clearInterval(pollingInterval);
|
if (pollingInterval) clearInterval(pollingInterval);
|
||||||
|
// Reduce el tiempo a 5 segundos para que parezca instantáneo
|
||||||
pollingInterval = setInterval(async () => {
|
pollingInterval = setInterval(async () => {
|
||||||
const modal = document.getElementById('importModal');
|
const modal = document.getElementById('importModal');
|
||||||
if (modal.classList.contains('hidden')) {
|
if (modal.classList.contains('hidden')) {
|
||||||
await loadInbox();
|
await loadInbox();
|
||||||
}
|
}
|
||||||
}, 30000);
|
}, 5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadGuilds() {
|
async function loadGuilds() {
|
||||||
@@ -280,8 +281,16 @@
|
|||||||
try {
|
try {
|
||||||
const resSvc = await fetch(`${API_URL}/providers/scraped`, { headers: { "Authorization": `Bearer ${localStorage.getItem("token")}` } });
|
const resSvc = await fetch(`${API_URL}/providers/scraped`, { headers: { "Authorization": `Bearer ${localStorage.getItem("token")}` } });
|
||||||
const dataSvc = await resSvc.json();
|
const dataSvc = await resSvc.json();
|
||||||
scrapedData = dataSvc.services || [];
|
|
||||||
|
|
||||||
|
// 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 compSelect = document.getElementById('filterCompany');
|
||||||
const currentVal = compSelect.value;
|
const currentVal = compSelect.value;
|
||||||
const uniqueCompanies = [...new Set(scrapedData.map(s => {
|
const uniqueCompanies = [...new Set(scrapedData.map(s => {
|
||||||
@@ -300,7 +309,6 @@
|
|||||||
document.getElementById('countTotal').innerText = scrapedData.length;
|
document.getElementById('countTotal').innerText = scrapedData.length;
|
||||||
|
|
||||||
renderFilteredInbox();
|
renderFilteredInbox();
|
||||||
} catch (e) { console.error("Error en loadInbox:", e); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildServiceCard(svc) {
|
function buildServiceCard(svc) {
|
||||||
@@ -313,7 +321,6 @@
|
|||||||
const fullAddr = `${addr} ${pop}`.trim();
|
const fullAddr = `${addr} ${pop}`.trim();
|
||||||
const phone = (raw['Teléfono'] || raw['TELEFONOS'] || raw['TELEFONO'] || "").match(/[6789]\d{8}/)?.[0] || "";
|
const phone = (raw['Teléfono'] || raw['TELEFONOS'] || raw['TELEFONO'] || "").match(/[6789]\d{8}/)?.[0] || "";
|
||||||
|
|
||||||
// CORRECCIÓN BLINDADA DEL GREMIO
|
|
||||||
let guildName = null;
|
let guildName = null;
|
||||||
const rawGuildId = svc.guild_id || raw['guild_id'] || raw.guild_id;
|
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>
|
<span class="text-[8px] font-bold text-red-400">Nadie aceptó</span>
|
||||||
</div>`;
|
</div>`;
|
||||||
} else {
|
} 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 = `
|
badgeEstado = `
|
||||||
<div class="flex flex-col items-end gap-1">
|
<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">
|
<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