Actualizar automatizaciones.html

This commit is contained in:
2026-02-14 18:02:46 +00:00
parent e759d6c1b7
commit 309fdbc7d3

View File

@@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Validación - IntegraRepara</title> <title>Validación - IntegraReparaPro</title>
<script src="https://cdn.tailwindcss.com"></script> <script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/lucide@latest"></script> <script src="https://unpkg.com/lucide@latest"></script>
<style> <style>
@@ -11,11 +11,9 @@
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.no-scrollbar::-webkit-scrollbar { display: none; } .no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; } .no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
.action-btn { transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); } .service-card { cursor: pointer; transition: all 0.2s ease; position: relative; }
.action-btn:hover:not(:disabled) { transform: translateY(-2px); } .service-card:hover:not(.archived) { transform: translateY(-2px); border-color: #3b82f6; box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1); }
/* Efecto de pulsación para la tarjeta */ .archived { opacity: 0.7; grayscale: 100%; cursor: not-allowed; }
.service-card { cursor: pointer; transition: all 0.2s ease; }
.service-card:hover { transform: scale(1.005); border-color: #3b82f6; }
</style> </style>
</head> </head>
<body class="bg-gray-50 text-gray-800 font-sans antialiased overflow-hidden text-left"> <body class="bg-gray-50 text-gray-800 font-sans antialiased overflow-hidden text-left">
@@ -34,37 +32,40 @@
<span class="bg-blue-600 p-2.5 rounded-xl text-white shadow-lg"><i data-lucide="bot"></i></span> <span class="bg-blue-600 p-2.5 rounded-xl text-white shadow-lg"><i data-lucide="bot"></i></span>
Buzón de Automatizaciones Buzón de Automatizaciones
</h2> </h2>
<p class="text-sm text-slate-500 mt-1 font-medium text-left">Expedientes capturados. Pulsa sobre cualquier servicio para validar.</p> <p class="text-sm text-slate-500 mt-1 font-medium">Pulsa sobre cualquier servicio activo para validar los datos.</p>
</div> </div>
<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 shadow-sm"> <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 shadow-sm">
<i data-lucide="refresh-cw" class="w-4 h-4"></i> Actualizar <i data-lucide="refresh-cw" class="w-4 h-4"></i> Actualizar
</button> </button>
</div> </div>
<div id="inboxContainer" class="space-y-4"></div> <div id="inboxContainer" class="space-y-4 text-left"></div>
</div> </div>
</main> </main>
</div> </div>
</div> </div>
<div id="importModal" class="fixed inset-0 bg-slate-900/70 hidden z-[100] flex items-center justify-center backdrop-blur-md p-2 text-left"> <div id="importModal" class="fixed inset-0 bg-slate-900/75 hidden z-[100] flex items-center justify-center backdrop-blur-md p-2">
<div class="bg-white rounded-[2.5rem] shadow-2xl w-full max-w-4xl flex flex-col max-h-[95vh] overflow-hidden border border-slate-200 fade-in text-left"> <div class="bg-white rounded-[2.5rem] shadow-2xl w-full max-w-4xl flex flex-col max-h-[95vh] overflow-hidden border border-slate-200 fade-in text-left">
<div class="px-8 pt-6 pb-4 flex justify-between items-center border-b border-slate-50 text-left"> <div class="px-8 pt-6 pb-4 flex justify-between items-center border-b border-slate-50">
<div class="flex items-center gap-4 text-left"> <div class="flex items-center gap-4 text-left">
<div id="modalCompanyLogo" class="w-12 h-12 rounded-xl bg-slate-50 border border-slate-100 p-2 flex items-center justify-center shadow-sm overflow-hidden"></div> <div id="modalCompanyLogo" class="w-12 h-12 rounded-xl bg-slate-50 border border-slate-100 p-2 flex items-center justify-center shadow-sm overflow-hidden"></div>
<div> <div>
<h3 class="text-xl font-black text-slate-800 tracking-tight">Validación de Expediente</h3> <div class="flex items-center gap-2">
<div class="flex items-center gap-2 mt-0.5"> <h3 class="text-xl font-black text-slate-800 tracking-tight">Validación de Expediente</h3>
<span id="displayRef" class="text-[10px] bg-slate-100 text-slate-500 px-2 py-0.5 rounded-lg font-bold border border-slate-200 uppercase tracking-tighter">REF: --</span> <div id="modalStatusBadge"></div>
</div>
<div class="flex items-center gap-2 mt-0.5 text-left">
<span id="displayRef" class="text-[10px] bg-slate-100 text-slate-500 px-2 py-0.5 rounded-lg font-bold border border-slate-200 uppercase">REF: --</span>
<span id="displayCompany" class="text-[10px] bg-blue-50 text-blue-600 px-2 py-0.5 rounded-lg font-bold border border-blue-100 uppercase truncate max-w-[250px]">--</span> <span id="displayCompany" class="text-[10px] bg-blue-50 text-blue-600 px-2 py-0.5 rounded-lg font-bold border border-blue-100 uppercase truncate max-w-[250px]">--</span>
</div> </div>
</div> </div>
</div> </div>
<div class="flex items-center gap-4"> <div class="flex items-center gap-4 text-left">
<div class="flex flex-col items-end mr-4 text-left"> <div class="flex flex-col items-end mr-4">
<span class="text-[9px] font-black text-slate-400 uppercase mb-1">Prioridad del Aviso</span> <span class="text-[9px] font-black text-slate-400 uppercase mb-1">Prioridad</span>
<select id="impUrgent" class="bg-slate-50 border border-slate-200 text-xs font-black px-3 py-1.5 rounded-xl outline-none focus:border-red-400 cursor-pointer"> <select id="impUrgent" class="bg-slate-50 border border-slate-200 text-xs font-black px-3 py-1.5 rounded-xl outline-none focus:border-red-400 cursor-pointer">
<option value="false">BAJA (Normal)</option> <option value="false">BAJA (Normal)</option>
<option value="true">🚨 MUY URGENTE</option> <option value="true">🚨 MUY URGENTE</option>
@@ -81,25 +82,25 @@
<div class="grid grid-cols-1 md:grid-cols-2 gap-4"> <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="bg-slate-50/50 p-3 rounded-2xl border border-slate-100 flex items-center gap-3"> <div class="bg-slate-50/50 p-3 rounded-2xl border border-slate-100 flex items-center gap-3">
<div class="bg-white p-2 rounded-xl shadow-sm text-slate-400"><i data-lucide="user"></i></div> <div class="bg-white p-2 rounded-xl shadow-sm text-slate-400"><i data-lucide="user" class="w-4 h-4"></i></div>
<div class="flex flex-col min-w-0 w-full"> <div class="flex flex-col min-w-0 w-full text-left">
<span class="text-[9px] font-black text-slate-400 uppercase mb-0.5">Titular Asegurado</span> <span class="text-[9px] font-black text-slate-400 uppercase mb-0.5">Asegurado</span>
<input type="text" id="impName" readonly class="bg-transparent border-none p-0 text-sm font-bold text-slate-700 outline-none focus:ring-0 truncate w-full"> <input type="text" id="impName" readonly class="bg-transparent border-none p-0 text-sm font-bold text-slate-700 outline-none w-full">
</div> </div>
</div> </div>
<div class="bg-slate-50/50 p-3 rounded-2xl border border-slate-100 flex items-center gap-3"> <div class="bg-slate-50/50 p-3 rounded-2xl border border-slate-100 flex items-center gap-3 text-left">
<div class="bg-white p-2 rounded-xl shadow-sm text-emerald-500"><i data-lucide="phone"></i></div> <div class="bg-white p-2 rounded-xl shadow-sm text-emerald-500"><i data-lucide="phone" class="w-4 h-4"></i></div>
<div class="flex flex-col min-w-0 w-full"> <div class="flex flex-col min-w-0 w-full text-left">
<span class="text-[9px] font-black text-slate-400 uppercase mb-0.5">Teléfono Móvil</span> <span class="text-[9px] font-black text-slate-400 uppercase mb-0.5">Teléfono</span>
<input type="text" id="impPhone" readonly class="bg-transparent border-none p-0 text-sm font-black text-emerald-600 outline-none focus:ring-0 w-full"> <input type="text" id="impPhone" readonly class="bg-transparent border-none p-0 text-sm font-black text-emerald-600 outline-none w-full">
</div> </div>
</div> </div>
</div> </div>
<div class="grid grid-cols-1 md:grid-cols-5 gap-3"> <div class="grid grid-cols-1 md:grid-cols-5 gap-3 text-left">
<div class="md:col-span-4 space-y-1"> <div class="md:col-span-4 space-y-1">
<label class="text-[9px] font-black text-blue-600 uppercase tracking-widest ml-2 flex items-center gap-1"> <label class="text-[9px] font-black text-blue-600 uppercase tracking-widest ml-2 flex items-center gap-1">
<i data-lucide="map-pin" class="w-3 h-3"></i> Dirección de la Reparación <i data-lucide="map-pin" class="w-3 h-3"></i> Dirección
</label> </label>
<input type="text" id="impAddress" required class="w-full border-2 border-slate-100 bg-white px-4 py-2.5 rounded-2xl text-sm font-medium outline-none focus:border-blue-500 shadow-sm"> <input type="text" id="impAddress" required class="w-full border-2 border-slate-100 bg-white px-4 py-2.5 rounded-2xl text-sm font-medium outline-none focus:border-blue-500 shadow-sm">
</div> </div>
@@ -109,32 +110,32 @@
</div> </div>
</div> </div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 p-5 rounded-[1.8rem] border-2 border-blue-50 bg-blue-50/30"> <div class="grid grid-cols-1 md:grid-cols-2 gap-4 p-5 rounded-[1.8rem] border-2 border-blue-50 bg-blue-50/30 text-left">
<div class="space-y-1"> <div class="space-y-1 text-left">
<label class="text-[9px] font-black text-blue-600 uppercase tracking-widest ml-2">Gremio Especialista *</label> <label class="text-[9px] font-black text-blue-600 uppercase tracking-widest ml-2">Gremio Especialista *</label>
<select id="impGuild" required onchange="loadOpsForGuild(this.value)" class="w-full border border-blue-100 bg-white px-3 py-2 rounded-xl text-sm font-bold outline-none focus:ring-2 focus:ring-blue-400 shadow-sm"> <select id="impGuild" required onchange="loadOpsForGuild(this.value)" class="w-full border border-blue-100 bg-white px-3 py-2 rounded-xl text-sm font-bold shadow-sm outline-none focus:ring-2 focus:ring-blue-400">
<option value="">-- Seleccionar Especialidad --</option> <option value="">-- Seleccionar Gremio --</option>
</select> </select>
</div> </div>
<div class="space-y-1"> <div class="space-y-1 text-left">
<label class="text-[9px] font-black text-slate-400 uppercase tracking-widest ml-2">Asignación Operario</label> <label class="text-[9px] font-black text-slate-400 uppercase tracking-widest ml-2">Asignación Operario</label>
<select id="impOperator" class="w-full border border-blue-100 bg-white px-3 py-2 rounded-xl text-sm font-bold outline-none focus:ring-2 focus:ring-blue-400 shadow-sm"> <select id="impOperator" class="w-full border border-blue-100 bg-white px-3 py-2 rounded-xl text-sm font-bold shadow-sm outline-none focus:ring-2 focus:ring-blue-400">
<option value="">-- Automática --</option> <option value="">-- Automática --</option>
</select> </select>
</div> </div>
</div> </div>
<div class="space-y-3"> <div class="space-y-3 text-left">
<div class="space-y-1 text-left"> <div class="space-y-1 text-left">
<label class="text-[9px] font-black text-slate-400 uppercase tracking-widest ml-2">Avería Detectada</label> <label class="text-[9px] font-black text-slate-400 uppercase tracking-widest ml-2">Avería Detectada</label>
<textarea id="impDesc" rows="2" class="w-full border border-slate-200 bg-white px-4 py-2 rounded-2xl text-sm font-medium text-slate-600 outline-none focus:border-blue-400 resize-none shadow-sm"></textarea> <textarea id="impDesc" rows="2" class="w-full border border-slate-200 bg-white px-4 py-2 rounded-2xl text-sm font-medium text-slate-600 outline-none focus:border-blue-400 resize-none shadow-sm"></textarea>
</div> </div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 text-left"> <div class="grid grid-cols-1 md:grid-cols-2 gap-4 text-left">
<div> <div class="text-left">
<label class="text-[9px] font-black text-amber-600 uppercase ml-2 mb-1 block">Notas Internas Oficina</label> <label class="text-[9px] font-black text-amber-600 uppercase ml-2 mb-1 block">Notas Oficina</label>
<textarea id="impNotesInt" rows="1" class="w-full border border-amber-100 bg-amber-50/30 px-3 py-2 rounded-xl text-xs outline-none focus:bg-white"></textarea> <textarea id="impNotesInt" rows="1" class="w-full border border-amber-100 bg-amber-50/30 px-3 py-2 rounded-xl text-xs outline-none focus:bg-white"></textarea>
</div> </div>
<div> <div class="text-left">
<label class="text-[9px] font-black text-blue-500 uppercase ml-2 mb-1 block">Instrucciones Operario</label> <label class="text-[9px] font-black text-blue-500 uppercase ml-2 mb-1 block">Instrucciones Operario</label>
<textarea id="impNotesExt" rows="1" class="w-full border border-blue-100 bg-blue-50/30 px-3 py-2 rounded-xl text-xs outline-none focus:bg-white"></textarea> <textarea id="impNotesExt" rows="1" class="w-full border border-blue-100 bg-blue-50/30 px-3 py-2 rounded-xl text-xs outline-none focus:bg-white"></textarea>
</div> </div>
@@ -143,19 +144,17 @@
<div class="flex items-center gap-3 pt-4 border-t"> <div class="flex items-center gap-3 pt-4 border-t">
<button type="button" onclick="saveDraftChanges(event)" class="bg-slate-100 hover:bg-slate-200 text-slate-600 font-black px-6 py-5 rounded-[1.8rem] transition-all flex items-center justify-center gap-2 active:scale-95 text-xs uppercase tracking-widest"> <button type="button" onclick="saveDraftChanges(event)" class="bg-slate-100 hover:bg-slate-200 text-slate-600 font-black px-6 py-5 rounded-[1.8rem] transition-all flex items-center justify-center gap-2 active:scale-95 text-xs uppercase tracking-widest">
<i data-lucide="save" class="w-4 h-4"></i> <i data-lucide="save" class="w-4 h-4"></i> <span>Guardar Borrador</span>
<span>Guardar Borrador</span>
</button> </button>
<button type="submit" class="flex-1 bg-slate-900 hover:bg-emerald-600 text-white font-black py-5 rounded-[1.8rem] shadow-xl shadow-slate-100 transition-all flex items-center justify-center gap-3 active:scale-95 text-sm uppercase tracking-[0.2em]"> <button type="submit" class="flex-1 bg-slate-900 hover:bg-emerald-600 text-white font-black py-5 rounded-[1.8rem] shadow-xl transition-all flex items-center justify-center gap-3 active:scale-95 text-sm uppercase tracking-[0.2em]">
<span>TRASPASAR A CRM</span> <span>TRASPASAR A CRM</span> <i data-lucide="send" class="w-5 h-5"></i>
<i data-lucide="send" class="w-5 h-5"></i>
</button> </button>
</div> </div>
</form> </form>
</div> </div>
</div> </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-[200] border border-white/10 text-left"><span id="toastMsg" class="font-bold text-sm"></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-[200] border border-white/10"><span id="toastMsg" class="font-bold text-sm text-left"></span></div>
<script src="js/layout.js"></script> <script src="js/layout.js"></script>
<script> <script>
@@ -213,10 +212,7 @@
async function loadInbox() { async function loadInbox() {
const container = document.getElementById('inboxContainer'); const container = document.getElementById('inboxContainer');
try { try {
const [resSvc, resMap] = await Promise.all([ const resSvc = await fetch(`${API_URL}/providers/scraped`, { headers: { "Authorization": `Bearer ${localStorage.getItem("token")}` } });
fetch(`${API_URL}/providers/scraped`, { headers: { "Authorization": `Bearer ${localStorage.getItem("token")}` } }),
fetch(`${API_URL}/discovery/mappings`, { headers: { "Authorization": `Bearer ${localStorage.getItem("token")}` } })
]);
const dataSvc = await resSvc.json(); const dataSvc = await resSvc.json();
scrapedData = dataSvc.services || []; scrapedData = dataSvc.services || [];
container.innerHTML = ""; container.innerHTML = "";
@@ -228,54 +224,54 @@
scrapedData.forEach(svc => { scrapedData.forEach(svc => {
const raw = svc.raw_data || {}; const raw = svc.raw_data || {};
const isArchived = svc.status === 'archived'; //
const statusLabel = isArchived ? 'ARCHIVADO' : 'SERVICIO ACTIVO'; //
const statusClass = isArchived ? 'bg-gray-100 text-gray-500 border-gray-200' : 'bg-emerald-50 text-emerald-600 border-emerald-100'; //
const name = raw['Nombre Cliente'] || raw['CLIENTE'] || "S/N"; const name = raw['Nombre Cliente'] || raw['CLIENTE'] || "S/N";
const addr = raw['Dirección'] || raw['DOMICILIO'] || ""; const addr = raw['Dirección'] || raw['DOMICILIO'] || "";
const pop = raw['Población'] || raw['POBLACION-PROVINCIA'] || ""; const pop = raw['Población'] || raw['POBLACION-PROVINCIA'] || "";
const fullAddr = `${addr} ${pop}`.trim(); const fullAddr = `${addr} ${pop}`.trim();
const companyName = raw['Compañía'] || raw['COMPAÑIA'] || raw['Procedencia'] || "";
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] || "";
const isBlocked = (!name || name.toUpperCase().includes('SIN NOMBRE') || !addr);
const isHome = svc.provider === 'homeserve'; //
const card = document.createElement('div'); const card = document.createElement('div');
// Clase service-card añadida para permitir el click en toda el área card.className = `service-card bg-white p-5 rounded-2xl border ${isArchived ? 'archived' : 'shadow-sm'} flex items-center justify-between transition-all group fade-in text-left`;
card.className = `service-card bg-white p-5 rounded-2xl border ${isBlocked ? 'opacity-50' : 'shadow-sm hover:border-blue-300'} flex items-center justify-between transition-all group fade-in text-left`;
card.onclick = (e) => { card.onclick = (e) => {
// Evitamos disparar el modal si se pulsa un botón de acción (Maps, WA, etc) if (e.target.closest('a') || e.target.closest('button')) return;
if (e.target.closest('a') || e.target.closest('.action-btn')) return; if (isArchived) {
if (!isBlocked) openEditor(svc.id); showToast("⚠️ Este servicio está ARCHIVADO y no se puede editar.", true);
} else {
openEditor(svc.id);
}
}; };
card.innerHTML = ` card.innerHTML = `
<div class="flex items-center gap-4 min-w-0"> <div class="flex items-center gap-4 min-w-0 text-left">
<div class="w-16 h-16 rounded-2xl flex flex-col items-center justify-center shrink-0 shadow-sm border border-slate-100 ${isHome ? 'bg-red-50 text-red-600' : 'bg-blue-50 text-blue-600'}"> <div class="w-16 h-16 rounded-2xl flex flex-col items-center justify-center shrink-0 shadow-sm border border-slate-100 ${isArchived ? 'bg-gray-200 text-gray-400' : (svc.provider === 'homeserve' ? 'bg-red-50 text-red-600' : 'bg-blue-50 text-blue-600')}">
<span class="text-[9px] font-black uppercase tracking-tighter">${isHome ? 'HOME' : 'MULTI'}</span> <span class="text-[9px] font-black uppercase tracking-tighter">${svc.provider === 'multiasistencia' ? 'MULTI' : 'HOME'}</span>
<i data-lucide="${isBlocked ? 'lock' : 'file-text'}" class="w-5 h-5 mt-0.5"></i> <i data-lucide="${isArchived ? 'lock' : 'file-text'}" class="w-5 h-5 mt-0.5"></i>
</div> </div>
<div class="w-12 h-12 rounded-xl bg-white border border-slate-100 p-2 flex items-center justify-center shrink-0 shadow-inner"> <div class="w-12 h-12 rounded-xl bg-white border border-slate-100 p-2 flex items-center justify-center shrink-0 shadow-inner">
<img src="${getLogoUrl(companyName)}" onerror="this.src='${companyLogos['DEFAULT']}'" class="max-w-full max-h-full object-contain"> <img src="${getLogoUrl(raw['Compañía'] || raw['COMPAÑIA'])}" onerror="this.src='${companyLogos['DEFAULT']}'" class="max-w-full max-h-full object-contain">
</div> </div>
<div class="min-w-0 text-left"> <div class="min-w-0 text-left">
<h3 class="font-black text-slate-800 truncate uppercase text-lg leading-tight">${isBlocked ? 'Bloqueado' : name}</h3> <div class="flex items-center gap-2 text-left">
<p class="text-xs text-slate-400 truncate italic mt-0.5">${isBlocked ? 'Pendiente de liberación' : fullAddr}</p> <h3 class="font-black text-slate-800 truncate uppercase text-lg leading-tight">${name}</h3>
<span class="text-[8px] font-black px-2 py-0.5 rounded-full border ${statusClass}">${statusLabel}</span>
</div>
<p class="text-xs text-slate-400 truncate italic mt-0.5">${fullAddr}</p>
<div class="flex gap-2 mt-2"> <div class="flex gap-2 mt-2">
<span class="text-[10px] bg-slate-100 text-slate-500 px-2 py-0.5 rounded-lg font-bold border">#${svc.service_ref}</span> <span class="text-[10px] bg-slate-100 text-slate-500 px-2 py-0.5 rounded-lg font-bold border">#${svc.service_ref}</span>
${phone ? `<span class="text-[10px] bg-emerald-50 text-emerald-600 px-2 py-0.5 rounded-lg font-bold border border-emerald-100">${phone}</span>` : ''}
</div> </div>
</div> </div>
</div> </div>
<div class="flex items-center gap-2"> <div class="flex items-center gap-2 text-left">
${!isBlocked ? ` ${!isArchived ? `
<div class="hidden group-hover:flex items-center gap-1 pr-4 border-r mr-2 transition-all"> <div class="hidden group-hover:flex items-center gap-1 pr-4 border-r mr-2 transition-all">
<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 shadow-sm"><i data-lucide="map" class="w-5 h-5"></i></a> <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 shadow-sm"><i data-lucide="map"></i></a>
${phone ? ` ${phone ? `<a href="https://wa.me/34${phone}" target="_blank" class="action-btn p-2.5 rounded-xl bg-slate-50 text-slate-400 hover:text-emerald-600 shadow-sm"><i data-lucide="message-square"></i></a>` : ''}
<a href="https://wa.me/34${phone}" target="_blank" class="action-btn p-2.5 rounded-xl bg-slate-50 text-slate-400 hover:text-emerald-600 shadow-sm"><i data-lucide="message-square" class="w-5 h-5"></i></a>
<a href="tel:${phone}" class="action-btn p-2.5 rounded-xl bg-slate-50 text-slate-400 hover:text-blue-600 shadow-sm"><i data-lucide="phone-call" class="w-5 h-5"></i></a>
` : ''}
</div> </div>
<div class="bg-blue-600 text-white p-4 rounded-2xl shadow-lg group-hover:scale-105 transition-all"><i data-lucide="chevron-right" class="w-6 h-6"></i></div>` : '<i data-lucide="shield-off" class="text-slate-300 mx-4"></i>'} <div class="bg-blue-600 text-white p-4 rounded-2xl shadow-lg group-hover:scale-105 transition-all"><i data-lucide="chevron-right" class="w-6 h-6"></i></div>` : ''}
</div>`; </div>`;
container.appendChild(card); container.appendChild(card);
}); });
@@ -289,9 +285,10 @@
const raw = svc.raw_data; const raw = svc.raw_data;
const companyName = raw['Compañía'] || raw['COMPAÑIA'] || raw['Procedencia'] || ""; const companyName = raw['Compañía'] || raw['COMPAÑIA'] || raw['Procedencia'] || "";
document.getElementById('modalCompanyLogo').innerHTML = `<img src="${getLogoUrl(companyName)}" class="max-w-full max-h-full object-contain">`;
document.getElementById('displayRef').innerText = `REF: ${svc.service_ref}`; document.getElementById('displayRef').innerText = `REF: ${svc.service_ref}`;
document.getElementById('displayCompany').innerText = companyName; document.getElementById('displayCompany').innerText = companyName;
document.getElementById('modalCompanyLogo').innerHTML = `<img src="${getLogoUrl(companyName)}" class="max-w-full max-h-full object-contain">`; document.getElementById('modalStatusBadge').innerHTML = `<span class="text-[9px] bg-emerald-50 text-emerald-600 px-3 py-1 rounded-full font-black border border-emerald-100">SERVICIO ACTIVO</span>`;
document.getElementById('impScrapedId').value = id; document.getElementById('impScrapedId').value = id;
document.getElementById('impName').value = raw['Nombre Cliente'] || raw['CLIENTE'] || "S/N"; document.getElementById('impName').value = raw['Nombre Cliente'] || raw['CLIENTE'] || "S/N";
@@ -321,7 +318,6 @@
const id = document.getElementById('impScrapedId').value; const id = document.getElementById('impScrapedId').value;
const btn = e.currentTarget; const btn = e.currentTarget;
btn.disabled = true; btn.disabled = true;
const payload = { const payload = {
name: document.getElementById('impName').value, name: document.getElementById('impName').value,
phone: document.getElementById('impPhone').value, phone: document.getElementById('impPhone').value,
@@ -334,7 +330,6 @@
client_notes: document.getElementById('impNotesExt').value, client_notes: document.getElementById('impNotesExt').value,
is_urgent: document.getElementById('impUrgent').value === 'true' is_urgent: document.getElementById('impUrgent').value === 'true'
}; };
try { try {
const res = await fetch(`${API_URL}/providers/scraped/${id}`, { const res = await fetch(`${API_URL}/providers/scraped/${id}`, {
method: 'PUT', method: 'PUT',
@@ -350,9 +345,8 @@
async function handleFinalImport(event) { async function handleFinalImport(event) {
event.preventDefault(); event.preventDefault();
const btn = event.submitter; const btn = event.submitter;
if(btn.type === 'button') return; // Evitar que el botón de borrador dispare el submit if(btn.type === 'button') return;
btn.disabled = true; btn.disabled = true;
const payload = { const payload = {
name: document.getElementById('impName').value, name: document.getElementById('impName').value,
phone: document.getElementById('impPhone').value, phone: document.getElementById('impPhone').value,
@@ -366,7 +360,6 @@
client_notes: document.getElementById('impNotesExt').value, client_notes: document.getElementById('impNotesExt').value,
is_urgent: document.getElementById('impUrgent').value === 'true' is_urgent: document.getElementById('impUrgent').value === 'true'
}; };
try { try {
const res = await fetch(`${API_URL}/providers/import/${document.getElementById('impScrapedId').value}`, { const res = await fetch(`${API_URL}/providers/import/${document.getElementById('impScrapedId').value}`, {
method: 'POST', method: 'POST',