Actualizar automatizaciones.html
This commit is contained in:
@@ -11,6 +11,8 @@
|
||||
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
|
||||
.no-scrollbar::-webkit-scrollbar { display: none; }
|
||||
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
|
||||
.action-btn { transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); }
|
||||
.action-btn:hover { transform: translateY(-2px); }
|
||||
</style>
|
||||
</head>
|
||||
<body class="bg-gray-50 text-gray-800 font-sans antialiased overflow-hidden">
|
||||
@@ -24,15 +26,18 @@
|
||||
<main class="flex-1 overflow-x-hidden overflow-y-auto bg-gray-50 p-6 relative">
|
||||
|
||||
<div id="automationView" class="fade-in">
|
||||
<div class="flex justify-between items-center mb-6">
|
||||
<div class="flex justify-between items-center mb-8">
|
||||
<div>
|
||||
<h2 class="text-2xl font-bold text-gray-800 flex items-center gap-2">
|
||||
<i data-lucide="bot" class="text-blue-600"></i> Buzón de Automatizaciones
|
||||
<h2 class="text-2xl font-black text-slate-800 flex items-center gap-3">
|
||||
<span class="bg-blue-600 p-2.5 rounded-xl text-white shadow-lg shadow-blue-100">
|
||||
<i data-lucide="bot" class="w-6 h-6"></i>
|
||||
</span>
|
||||
Buzón de Automatizaciones
|
||||
</h2>
|
||||
<p class="text-sm text-gray-500 mt-1">Valida e importa servicios detectados por los robots.</p>
|
||||
<p class="text-sm text-slate-500 mt-1 font-medium">Validación rápida de expedientes externos.</p>
|
||||
</div>
|
||||
<button onclick="loadInbox()" class="bg-blue-600 hover:bg-blue-700 text-white px-5 py-2.5 rounded-xl shadow-lg flex items-center gap-2 font-medium transition-all transform hover:scale-105">
|
||||
<i data-lucide="refresh-cw" class="w-5 h-5"></i> Actualizar Buzón
|
||||
<button onclick="loadInbox()" class="bg-white border-2 border-slate-200 hover:border-blue-600 hover:text-blue-600 text-slate-600 px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 transition-all active:scale-95">
|
||||
<i data-lucide="refresh-cw" class="w-4 h-4"></i> Actualizar
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -43,75 +48,77 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="importModal" class="fixed inset-0 bg-black bg-opacity-50 hidden z-50 flex items-center justify-center backdrop-blur-sm p-4">
|
||||
<div class="bg-white rounded-xl shadow-2xl w-full max-w-2xl p-6 flex flex-col max-h-[90vh] overflow-y-auto no-scrollbar">
|
||||
<div class="flex justify-between items-center mb-6 border-b pb-4">
|
||||
<h3 class="text-xl font-bold text-gray-800 flex items-center gap-2">
|
||||
<i data-lucide="file-check" class="text-green-600"></i> Validar Datos de Importación
|
||||
<div id="importModal" class="fixed inset-0 bg-slate-900/60 hidden z-50 flex items-center justify-center backdrop-blur-md p-4">
|
||||
<div class="bg-white rounded-3xl shadow-2xl w-full max-w-2xl flex flex-col max-h-[90vh] overflow-hidden border border-white/20">
|
||||
<div class="p-6 border-b flex justify-between items-center bg-slate-50">
|
||||
<h3 class="text-xl font-black text-slate-800 flex items-center gap-2">
|
||||
<i data-lucide="shield-check" class="text-emerald-500"></i> Validar Importación
|
||||
</h3>
|
||||
<button onclick="closeModal()" class="text-gray-400 hover:text-gray-600"><i data-lucide="x" class="w-6 h-6"></i></button>
|
||||
<button onclick="closeModal()" class="bg-white p-2 rounded-full shadow-sm hover:bg-red-50 hover:text-red-500 transition-all">
|
||||
<i data-lucide="x" class="w-5 h-5"></i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<form id="importForm" onsubmit="handleImportSubmit(event)" class="space-y-5">
|
||||
<form id="importForm" onsubmit="handleImportSubmit(event)" class="p-8 space-y-6 overflow-y-auto no-scrollbar">
|
||||
<input type="hidden" id="scrapedId">
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-[10px] font-bold text-gray-400 uppercase mb-1">Nombre del Cliente</label>
|
||||
<input type="text" id="imp_name" required class="w-full border p-2.5 rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div class="space-y-1.5">
|
||||
<label class="text-[11px] font-black text-slate-400 uppercase tracking-widest">Nombre Cliente</label>
|
||||
<input type="text" id="imp_name" required class="w-full border-2 border-slate-100 bg-slate-50 p-3 rounded-2xl text-sm focus:border-blue-500 focus:bg-white outline-none font-bold transition-all">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-[10px] font-bold text-gray-400 uppercase mb-1">Teléfono Principal (Limpio)</label>
|
||||
<input type="text" id="imp_phone" required class="w-full border p-2.5 rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none font-mono">
|
||||
<div id="imp_phone_extra" class="text-[10px] text-gray-400 mt-1 italic"></div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="text-[11px] font-black text-slate-400 uppercase tracking-widest">Teléfono Principal</label>
|
||||
<input type="text" id="imp_phone" required class="w-full border-2 border-slate-100 bg-slate-50 p-3 rounded-2xl text-sm focus:border-blue-500 focus:bg-white outline-none font-black text-blue-600 tracking-tighter">
|
||||
<div id="imp_phone_extra" class="text-[10px] text-slate-400 font-medium px-1"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-4 gap-4">
|
||||
<div class="md:col-span-3">
|
||||
<label class="block text-[10px] font-bold text-gray-400 uppercase mb-1">Dirección y Población</label>
|
||||
<input type="text" id="imp_address" required class="w-full border p-2.5 rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none">
|
||||
<div class="grid grid-cols-1 md:grid-cols-4 gap-6">
|
||||
<div class="md:col-span-3 space-y-1.5">
|
||||
<label class="text-[11px] font-black text-slate-400 uppercase tracking-widest">Dirección completa + Población</label>
|
||||
<div class="relative">
|
||||
<i data-lucide="map" class="w-4 h-4 absolute left-4 top-3.5 text-slate-300"></i>
|
||||
<input type="text" id="imp_address" required class="w-full border-2 border-slate-100 bg-slate-50 pl-11 pr-4 py-3 rounded-2xl text-sm focus:border-blue-500 focus:bg-white outline-none font-medium">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-[10px] font-bold text-gray-400 uppercase mb-1">C. Postal</label>
|
||||
<input type="text" id="imp_cp" required class="w-full border p-2.5 rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none font-mono">
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="text-[11px] font-black text-slate-400 uppercase tracking-widest">C. Postal</label>
|
||||
<input type="text" id="imp_cp" required class="w-full border-2 border-slate-100 bg-slate-50 p-3 rounded-2xl text-sm focus:border-blue-500 focus:bg-white outline-none font-black text-center">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-[10px] font-bold text-gray-400 uppercase mb-1">Descripción del Trabajo</label>
|
||||
<textarea id="imp_desc" rows="4" class="w-full border p-3 rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none"></textarea>
|
||||
<div class="space-y-1.5">
|
||||
<label class="text-[11px] font-black text-slate-400 uppercase tracking-widest">Descripción de Avería</label>
|
||||
<textarea id="imp_desc" rows="4" class="w-full border-2 border-slate-100 bg-slate-50 p-4 rounded-2xl text-sm focus:border-blue-500 focus:bg-white outline-none transition-all" placeholder="Detalles del trabajo..."></textarea>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
<div>
|
||||
<label class="block text-[10px] font-bold text-gray-400 uppercase mb-1">Referencia</label>
|
||||
<input type="text" id="imp_ref" class="w-full border p-2.5 rounded-lg text-sm bg-gray-50" readonly>
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
|
||||
<div class="space-y-1.5">
|
||||
<label class="text-[11px] font-black text-slate-400 uppercase tracking-widest">Ref. Expediente</label>
|
||||
<input type="text" id="imp_ref" class="w-full border-2 border-slate-50 bg-slate-100 p-3 rounded-2xl text-sm font-bold text-slate-500" readonly>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-[10px] font-bold text-gray-400 uppercase mb-1">Compañía / Origen</label>
|
||||
<input type="text" id="imp_company" class="w-full border p-2.5 rounded-lg text-sm bg-gray-50 font-bold text-blue-600" readonly>
|
||||
<div class="space-y-1.5">
|
||||
<label class="text-[11px] font-black text-slate-400 uppercase tracking-widest">Origen (Proveedor - Cía)</label>
|
||||
<input type="text" id="imp_company" class="w-full border-2 border-slate-50 bg-slate-100 p-3 rounded-2xl text-sm font-black text-blue-800" readonly>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-[10px] font-bold text-gray-400 uppercase mb-1">Prioridad</label>
|
||||
<select id="imp_urgent" class="w-full border p-2.5 rounded-lg text-sm bg-white outline-none">
|
||||
<div class="space-y-1.5">
|
||||
<label class="text-[11px] font-black text-slate-400 uppercase tracking-widest">Prioridad</label>
|
||||
<select id="imp_urgent" class="w-full border-2 border-slate-100 bg-white p-3 rounded-2xl text-sm font-bold outline-none focus:border-blue-500">
|
||||
<option value="false">Normal</option>
|
||||
<option value="true">🚨 URGENTE</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pt-4 flex gap-3">
|
||||
<button type="button" onclick="closeModal()" class="flex-1 bg-gray-100 text-gray-600 py-3 rounded-xl font-bold hover:bg-gray-200 transition-all">Cancelar</button>
|
||||
<button type="submit" id="btnImport" class="flex-[2] bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 rounded-xl shadow-lg transition-all flex justify-center items-center gap-2">
|
||||
<i data-lucide="download-cloud"></i> IMPORTAR AL CRM
|
||||
<button type="submit" id="btnImport" class="w-full bg-slate-900 hover:bg-blue-600 text-white font-black py-4 rounded-2xl shadow-xl transition-all flex justify-center items-center gap-3 active:scale-95 mt-4">
|
||||
<i data-lucide="plus-circle"></i> CREAR SERVICIO EN CRM
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="toast" class="fixed bottom-5 right-5 bg-slate-800 text-white px-6 py-3 rounded-lg shadow-2xl hidden z-[60]"><span id="toastMsg"></span></div>
|
||||
<div id="toast" class="fixed bottom-8 right-8 bg-slate-900 text-white px-8 py-4 rounded-2xl shadow-2xl hidden z-[60] border border-white/10"><span id="toastMsg" class="font-bold text-sm"></span></div>
|
||||
|
||||
<script src="js/layout.js"></script>
|
||||
<script>
|
||||
@@ -120,7 +127,7 @@
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
if (!localStorage.getItem("token")) window.location.href = "index.html";
|
||||
loadInbox();
|
||||
setTimeout(loadInbox, 200);
|
||||
});
|
||||
|
||||
async function loadInbox() {
|
||||
@@ -136,7 +143,12 @@
|
||||
scrapedData = dataSvc.services || [];
|
||||
|
||||
if(scrapedData.length === 0) {
|
||||
container.innerHTML = '<div class="p-12 text-center text-gray-400 bg-white rounded-xl border border-dashed border-gray-200 shadow-sm">No hay expedientes pendientes.</div>';
|
||||
container.innerHTML = `<div class="bg-white p-20 rounded-3xl border-2 border-dashed border-slate-200 text-center flex flex-col items-center">
|
||||
<div class="bg-emerald-50 text-emerald-500 p-5 rounded-full mb-4"><i data-lucide="check-circle" class="w-10 h-10"></i></div>
|
||||
<h3 class="text-xl font-black text-slate-800">¡Todo al día!</h3>
|
||||
<p class="text-slate-400 mt-1">No hay nuevos expedientes externos para procesar.</p>
|
||||
</div>`;
|
||||
lucide.createIcons();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -145,39 +157,51 @@
|
||||
const raw = svc.raw_data || {};
|
||||
const myMap = mappings.filter(m => m.provider === svc.provider);
|
||||
|
||||
const name = raw[myMap.find(m => m.target_key === 'clientName')?.original_key] || "Desconocido";
|
||||
const name = raw[myMap.find(m => m.target_key === 'clientName')?.original_key] || "Expediente sin nombre";
|
||||
const addr = raw[myMap.find(m => m.target_key === 'address')?.original_key] || "";
|
||||
const pop = raw[myMap.find(m => m.target_key === 'poblacion')?.original_key] || "";
|
||||
const fullAddr = `${addr} ${pop}`.trim() || "Sin dirección";
|
||||
const fullAddr = `${addr} ${pop}`.trim() || "Sin ubicación";
|
||||
|
||||
const rawPhone = raw[myMap.find(m => m.target_key === 'phone')?.original_key] || raw['Teléfono'] || "";
|
||||
const cleanPhone = rawPhone.match(/[6789]\d{8}/) ? rawPhone.match(/[6789]\d{8}/)[0] : "S/T";
|
||||
const cleanPhone = rawPhone.match(/[6789]\d{8}/) ? rawPhone.match(/[6789]\d{8}/)[0] : "";
|
||||
|
||||
// Acortar nombre de proveedor
|
||||
const shortProv = svc.provider.toUpperCase().replace('MULTIASISTENCIA', 'MULTI');
|
||||
|
||||
const card = document.createElement('div');
|
||||
card.className = "bg-white p-5 rounded-xl border border-gray-100 shadow-sm flex items-center justify-between hover:border-blue-200 transition-all fade-in";
|
||||
card.className = "bg-white p-6 rounded-2xl border border-slate-100 shadow-sm flex items-center justify-between hover:shadow-md transition-all fade-in group";
|
||||
card.innerHTML = `
|
||||
<div class="flex items-center gap-6 min-w-0">
|
||||
<div class="w-16 h-16 rounded-xl flex flex-col items-center justify-center shrink-0 ${svc.provider === 'homeserve' ? 'bg-red-50 text-red-600' : 'bg-blue-50 text-blue-600'}">
|
||||
<span class="text-[9px] font-black uppercase tracking-tighter">${svc.provider}</span>
|
||||
<i data-lucide="file-text" class="w-5 h-5 mt-1"></i>
|
||||
<div class="w-14 h-14 rounded-2xl flex flex-col items-center justify-center shrink-0 ${svc.provider === 'homeserve' ? 'bg-red-50 text-red-600' : 'bg-blue-50 text-blue-600'}">
|
||||
<span class="text-[8px] font-black uppercase tracking-widest">${shortProv}</span>
|
||||
<i data-lucide="file-text" class="w-5 h-5 mt-0.5"></i>
|
||||
</div>
|
||||
<div class="min-w-0">
|
||||
<h3 class="font-bold text-gray-900 truncate text-lg">${name}</h3>
|
||||
<p class="text-xs text-gray-500 flex items-center gap-1.5 mt-0.5 truncate"><i data-lucide="map-pin" class="w-3.5 h-3.5"></i> ${fullAddr}</p>
|
||||
<div class="mt-2 flex gap-2">
|
||||
<span class="text-[10px] bg-gray-100 text-gray-600 px-2 py-0.5 rounded font-bold border border-gray-200">#${svc.service_ref}</span>
|
||||
<span class="text-[10px] bg-blue-50 text-blue-600 px-2 py-0.5 rounded font-bold border border-blue-100">${cleanPhone}</span>
|
||||
<h3 class="font-black text-slate-800 truncate text-lg">${name}</h3>
|
||||
<p class="text-xs text-slate-400 flex items-center gap-1.5 mt-0.5 font-medium truncate"><i data-lucide="map-pin" class="w-3 h-3 text-slate-300"></i> ${fullAddr}</p>
|
||||
<div class="mt-3 flex gap-3">
|
||||
<span class="text-[10px] bg-slate-100 text-slate-500 px-2.5 py-1 rounded-lg font-black border border-slate-200">#${svc.service_ref}</span>
|
||||
${cleanPhone ? `<span class="text-[10px] bg-emerald-50 text-emerald-600 px-2.5 py-1 rounded-lg font-black border border-emerald-100">${cleanPhone}</span>` : ''}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button onclick="openEditor(${svc.id})" class="bg-blue-600 text-white p-3 rounded-xl transition-all shadow-lg active:scale-95">
|
||||
<i data-lucide="edit-3" class="w-5 h-5"></i>
|
||||
<div class="flex items-center gap-2">
|
||||
<div class="hidden group-hover:flex items-center gap-1 pr-4 border-r border-slate-100 mr-2 fade-in">
|
||||
<a href="https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(fullAddr)}" target="_blank" class="action-btn p-2.5 rounded-xl bg-slate-50 text-slate-400 hover:text-blue-600 hover:bg-blue-50" title="Google Maps"><i data-lucide="map" class="w-5 h-5"></i></a>
|
||||
${cleanPhone ? `
|
||||
<a href="https://wa.me/34${cleanPhone}" target="_blank" class="action-btn p-2.5 rounded-xl bg-slate-50 text-slate-400 hover:text-emerald-600 hover:bg-emerald-50" title="WhatsApp"><i data-lucide="message-square" class="w-5 h-5"></i></a>
|
||||
<a href="tel:${cleanPhone}" class="action-btn p-2.5 rounded-xl bg-slate-50 text-slate-400 hover:text-blue-600 hover:bg-blue-50" title="Llamar"><i data-lucide="phone-call" class="w-5 h-5"></i></a>
|
||||
` : ''}
|
||||
</div>
|
||||
<button onclick="openEditor(${svc.id})" class="bg-blue-600 hover:bg-slate-900 text-white p-4 rounded-2xl transition-all shadow-lg shadow-blue-100 active:scale-90" title="Editar e Importar">
|
||||
<i data-lucide="edit-3" class="w-6 h-6"></i>
|
||||
</button>
|
||||
</div>
|
||||
`;
|
||||
container.appendChild(card);
|
||||
});
|
||||
lucide.createIcons();
|
||||
} catch (e) { showToast("Error de conexión", true); }
|
||||
} catch (e) { showToast("Sincronización interrumpida", true); }
|
||||
}
|
||||
|
||||
function openEditor(scrapedId) {
|
||||
@@ -186,26 +210,27 @@
|
||||
const raw = svc.raw_data;
|
||||
const myMap = mappings.filter(m => m.provider === svc.provider);
|
||||
|
||||
// 1. LIMPIEZA DE TELÉFONO
|
||||
// 1. LIMPIEZA DE TELÉFONO QUIRÚRGICA
|
||||
const phoneVal = raw[myMap.find(m => m.target_key === 'phone')?.original_key] || raw['Teléfono'] || "";
|
||||
const phoneMatch = phoneVal.match(/[6789]\d{8}/);
|
||||
document.getElementById('imp_phone').value = phoneMatch ? phoneMatch[0] : "";
|
||||
document.getElementById('imp_phone_extra').innerText = phoneVal !== (phoneMatch ? phoneMatch[0] : "") ? `Dato original: ${phoneVal}` : "";
|
||||
document.getElementById('imp_phone_extra').innerHTML = phoneVal !== (phoneMatch ? phoneMatch[0] : "") ? `<i data-lucide="info" class="w-2.5 h-2.5 inline mr-1"></i>Dato capturado: ${phoneVal}` : "";
|
||||
|
||||
// 2. LIMPIEZA DE CP Y DIRECCIÓN
|
||||
// 2. CONCATENACIÓN DIRECCIÓN + POBLACIÓN
|
||||
const addr = raw[myMap.find(m => m.target_key === 'address')?.original_key] || "";
|
||||
const pop = raw[myMap.find(m => m.target_key === 'poblacion')?.original_key] || "";
|
||||
document.getElementById('imp_address').value = `${addr} ${pop}`.trim();
|
||||
|
||||
// 3. LIMPIEZA CÓDIGO POSTAL
|
||||
const cpVal = raw[myMap.find(m => m.target_key === 'cp')?.original_key] || raw['Población_CP'] || "";
|
||||
const cpMatch = cpVal.match(/\b\d{5}\b/);
|
||||
|
||||
document.getElementById('imp_address').value = `${addr} ${pop}`.trim();
|
||||
document.getElementById('imp_cp').value = cpMatch ? cpMatch[0] : "";
|
||||
|
||||
// 3. PROVEEDOR - COMPAÑÍA
|
||||
// 4. PROVEEDOR - COMPAÑÍA (Formato: ROBOT - COMPAÑÍA)
|
||||
const cia = raw[myMap.find(m => m.target_key === 'compania')?.original_key] || raw['Compañía'] || "";
|
||||
document.getElementById('imp_company').value = `${svc.provider.toUpperCase()} - ${cia}`;
|
||||
|
||||
// 4. RESTO DE CAMPOS
|
||||
// 5. RESTO DE DATOS
|
||||
document.getElementById('scrapedId').value = scrapedId;
|
||||
document.getElementById('imp_name').value = raw[myMap.find(m => m.target_key === 'clientName')?.original_key] || "";
|
||||
document.getElementById('imp_ref').value = svc.service_ref;
|
||||
@@ -221,13 +246,14 @@
|
||||
async function handleImportSubmit(e) {
|
||||
e.preventDefault();
|
||||
const btn = document.getElementById('btnImport');
|
||||
btn.disabled = true; btn.innerText = "IMPORTANDO...";
|
||||
const originalText = btn.innerHTML;
|
||||
btn.disabled = true; btn.innerText = "Procesando...";
|
||||
|
||||
const payload = {
|
||||
name: document.getElementById('imp_name').value,
|
||||
phone: document.getElementById('imp_phone').value,
|
||||
address: document.getElementById('imp_address').value,
|
||||
description: `CP: ${document.getElementById('imp_cp').value}\n${document.getElementById('imp_desc').value}`,
|
||||
description: `C.P: ${document.getElementById('imp_cp').value}\n${document.getElementById('imp_desc').value}`,
|
||||
company_ref: document.getElementById('imp_ref').value,
|
||||
is_urgent: document.getElementById('imp_urgent').value === 'true'
|
||||
};
|
||||
@@ -239,19 +265,19 @@
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
if(res.ok) {
|
||||
showToast("✅ Servicio importado");
|
||||
showToast("✅ Importación completada.");
|
||||
closeModal();
|
||||
loadInbox();
|
||||
} else { showToast("Error al importar", true); }
|
||||
} catch (e) { showToast("Error conexión", true); }
|
||||
finally { btn.disabled = false; btn.innerHTML = '<i data-lucide="download-cloud"></i> IMPORTAR AL CRM'; lucide.createIcons(); }
|
||||
} else { showToast("No se pudo completar la importación.", true); }
|
||||
} catch (e) { showToast("Error de conexión con el servidor.", true); }
|
||||
finally { btn.disabled = false; btn.innerHTML = originalText; lucide.createIcons(); }
|
||||
}
|
||||
|
||||
function showToast(msg, isError = false) {
|
||||
const t = document.getElementById('toast'), m = document.getElementById('toastMsg');
|
||||
t.className = `fixed bottom-5 right-5 px-6 py-3 rounded-lg shadow-2xl z-[60] flex items-center gap-3 ${isError ? 'bg-red-600' : 'bg-slate-800'} text-white font-medium`;
|
||||
t.className = `fixed bottom-8 right-8 px-8 py-4 rounded-2xl shadow-2xl z-[60] flex items-center gap-3 transition-all ${isError ? 'bg-red-600' : 'bg-slate-900'} text-white border border-white/10`;
|
||||
m.innerText = msg; t.classList.remove('hidden');
|
||||
setTimeout(() => t.classList.add('hidden'), 3000);
|
||||
setTimeout(() => t.classList.add('hidden'), 4000);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user