Actualizar automatizaciones.html

This commit is contained in:
2026-02-13 22:43:51 +00:00
parent af35b43ae7
commit 51be82d9f7

View File

@@ -11,8 +11,8 @@
@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); } .action-btn { transition: all 0.2s ease; }
.action-btn:hover { transform: translateY(-2px); } .action-btn:hover:not(:disabled) { transform: translateY(-2px); }
</style> </style>
</head> </head>
<body class="bg-gray-50 text-gray-800 font-sans antialiased overflow-hidden"> <body class="bg-gray-50 text-gray-800 font-sans antialiased overflow-hidden">
@@ -25,7 +25,7 @@
<main class="flex-1 overflow-x-hidden overflow-y-auto bg-gray-50 p-6 relative"> <main class="flex-1 overflow-x-hidden overflow-y-auto bg-gray-50 p-6 relative">
<div id="automationView" class="fade-in"> <div id="automationView" class="fade-in max-w-6xl mx-auto">
<div class="flex justify-between items-center mb-8"> <div class="flex justify-between items-center mb-8">
<div> <div>
<h2 class="text-2xl font-black text-slate-800 flex items-center gap-3"> <h2 class="text-2xl font-black text-slate-800 flex items-center gap-3">
@@ -34,9 +34,9 @@
</span> </span>
Buzón de Automatizaciones Buzón de Automatizaciones
</h2> </h2>
<p class="text-sm text-slate-500 mt-1 font-medium">Validación rápida de expedientes externos.</p> <p class="text-sm text-slate-500 mt-1 font-medium">Gestiona e importa los avisos capturados por los robots.</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"> <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>
@@ -49,10 +49,10 @@
</div> </div>
<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 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="bg-white rounded-3xl shadow-2xl w-full max-w-2xl flex flex-col max-h-[90vh] overflow-hidden">
<div class="p-6 border-b flex justify-between items-center bg-slate-50"> <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"> <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 <i data-lucide="clipboard-check" class="text-emerald-500"></i> Revisar Datos
</h3> </h3>
<button onclick="closeModal()" class="bg-white p-2 rounded-full shadow-sm hover:bg-red-50 hover:text-red-500 transition-all"> <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> <i data-lucide="x" class="w-5 h-5"></i>
@@ -64,46 +64,43 @@
<div class="grid grid-cols-1 md:grid-cols-2 gap-6"> <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div class="space-y-1.5"> <div class="space-y-1.5">
<label class="text-[11px] font-black text-slate-400 uppercase tracking-widest">Nombre Cliente</label> <label class="text-[11px] font-black text-slate-400 uppercase tracking-widest">Nombre del 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"> <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">
</div> </div>
<div class="space-y-1.5"> <div class="space-y-1.5">
<label class="text-[11px] font-black text-slate-400 uppercase tracking-widest">Teléfono Principal</label> <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"> <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">
<div id="imp_phone_extra" class="text-[10px] text-slate-400 font-medium px-1"></div> <div id="imp_phone_extra" class="text-[10px] text-slate-400 italic px-1"></div>
</div> </div>
</div> </div>
<div class="grid grid-cols-1 md:grid-cols-4 gap-6"> <div class="grid grid-cols-1 md:grid-cols-4 gap-6">
<div class="md:col-span-3 space-y-1.5"> <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> <label class="text-[11px] font-black text-slate-400 uppercase tracking-widest">Dirección y Población</label>
<div class="relative"> <input type="text" id="imp_address" 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-medium">
<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> </div>
<div class="space-y-1.5"> <div class="space-y-1.5">
<label class="text-[11px] font-black text-slate-400 uppercase tracking-widest">C. Postal</label> <label class="text-[11px] font-black text-slate-400 uppercase tracking-widest">Código 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"> <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> </div>
<div class="space-y-1.5"> <div class="space-y-1.5">
<label class="text-[11px] font-black text-slate-400 uppercase tracking-widest">Descripción de Avería</label> <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> <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" placeholder="Detalles extraídos..."></textarea>
</div> </div>
<div class="grid grid-cols-1 md:grid-cols-3 gap-6"> <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
<div class="space-y-1.5"> <div>
<label class="text-[11px] font-black text-slate-400 uppercase tracking-widest">Ref. Expediente</label> <label class="text-[11px] font-black text-slate-400 uppercase tracking-widest">Referencia</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> <input type="text" id="imp_ref" class="w-full border-2 border-slate-100 bg-slate-100 p-3 rounded-2xl text-sm font-bold text-slate-500" readonly>
</div> </div>
<div class="space-y-1.5"> <div>
<label class="text-[11px] font-black text-slate-400 uppercase tracking-widest">Origen (Proveedor - Cía)</label> <label class="text-[11px] font-black text-slate-400 uppercase tracking-widest">Compañí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> <input type="text" id="imp_company" class="w-full border-2 border-slate-100 bg-slate-100 p-3 rounded-2xl text-sm font-black text-blue-800" readonly>
</div> </div>
<div class="space-y-1.5"> <div>
<label class="text-[11px] font-black text-slate-400 uppercase tracking-widest">Prioridad</label> <label class="text-[11px] font-black text-slate-400 uppercase tracking-widest">Urgencia</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"> <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="false">Normal</option>
<option value="true">🚨 URGENTE</option> <option value="true">🚨 URGENTE</option>
@@ -111,8 +108,8 @@
</div> </div>
</div> </div>
<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"> <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 uppercase tracking-widest">
<i data-lucide="plus-circle"></i> CREAR SERVICIO EN CRM <i data-lucide="plus-circle"></i> Importar a Servicios
</button> </button>
</form> </form>
</div> </div>
@@ -145,8 +142,8 @@
if(scrapedData.length === 0) { if(scrapedData.length === 0) {
container.innerHTML = `<div class="bg-white p-20 rounded-3xl border-2 border-dashed border-slate-200 text-center flex flex-col items-center"> 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> <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> <h3 class="text-xl font-black text-slate-800">Buzón al día</h3>
<p class="text-slate-400 mt-1">No hay nuevos expedientes externos para procesar.</p> <p class="text-slate-400 mt-1">No hay nuevos expedientes para validar.</p>
</div>`; </div>`;
lucide.createIcons(); lucide.createIcons();
return; return;
@@ -157,45 +154,58 @@
const raw = svc.raw_data || {}; const raw = svc.raw_data || {};
const myMap = mappings.filter(m => m.provider === svc.provider); const myMap = mappings.filter(m => m.provider === svc.provider);
const name = raw[myMap.find(m => m.target_key === 'clientName')?.original_key] || "Expediente sin nombre"; // Extracción de datos
const addr = raw[myMap.find(m => m.target_key === 'address')?.original_key] || ""; const rawName = raw[myMap.find(m => m.target_key === 'clientName')?.original_key] || "";
const pop = raw[myMap.find(m => m.target_key === 'poblacion')?.original_key] || ""; const rawAddr = raw[myMap.find(m => m.target_key === 'address')?.original_key] || "";
const fullAddr = `${addr} ${pop}`.trim() || "Sin ubicación"; const rawPop = raw[myMap.find(m => m.target_key === 'poblacion')?.original_key] || "";
const fullAddr = `${rawAddr} ${rawPop}`.trim();
const rawPhone = raw[myMap.find(m => m.target_key === 'phone')?.original_key] || raw['Teléfono'] || ""; 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] : ""; const cleanPhone = rawPhone.match(/[6789]\d{8}/) ? rawPhone.match(/[6789]\d{8}/)[0] : "";
// Acortar nombre de proveedor // Lógica de Bloqueo (Candado)
const shortProv = svc.provider.toUpperCase().replace('MULTIASISTENCIA', 'MULTI'); const isBlocked = (!rawName || rawName.toLowerCase().includes('expediente sin nombre') || !rawAddr);
const shortProv = svc.provider === 'multiasistencia' ? 'MULTI' : 'HOME';
const card = document.createElement('div'); const card = document.createElement('div');
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.className = `bg-white p-5 rounded-2xl border ${isBlocked ? 'border-slate-200 bg-slate-50/50' : 'border-slate-100 shadow-sm'} flex items-center justify-between hover:shadow-md transition-all fade-in group relative overflow-hidden`;
card.innerHTML = ` card.innerHTML = `
${isBlocked ? '<div class="absolute top-0 left-0 w-1 h-full bg-slate-400"></div>' : `<div class="absolute top-0 left-0 w-1 h-full ${svc.provider === 'homeserve' ? 'bg-red-500' : 'bg-blue-600'}"></div>`}
<div class="flex items-center gap-6 min-w-0"> <div class="flex items-center gap-6 min-w-0">
<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'}"> <div class="w-14 h-14 rounded-2xl flex flex-col items-center justify-center shrink-0 ${isBlocked ? 'bg-slate-200 text-slate-500' : (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> <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> <i data-lucide="${isBlocked ? 'lock' : 'file-text'}" class="w-5 h-5 mt-0.5"></i>
</div> </div>
<div class="min-w-0"> <div class="min-w-0">
<h3 class="font-black text-slate-800 truncate text-lg">${name}</h3> <h3 class="font-black ${isBlocked ? 'text-slate-400' : 'text-slate-800'} truncate text-lg uppercase">${isBlocked ? 'Expediente Bloqueado en Compañía' : (rawName || 'Nombre no detectado')}</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> <p class="text-xs ${isBlocked ? 'text-slate-300' : 'text-slate-400'} flex items-center gap-1.5 mt-0.5 font-medium truncate italic">
<i data-lucide="map-pin" class="w-3 h-3"></i> ${isBlocked ? 'Pendiente de liberación de datos' : (fullAddr || 'Sin dirección')}
</p>
${!isBlocked ? `
<div class="mt-3 flex gap-3"> <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> <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>` : ''} ${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>
</div> </div>
</div>
<div class="flex items-center gap-2"> <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"> ${!isBlocked ? `
<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> <div class="hidden group-hover:flex items-center gap-1 pr-4 border-r border-slate-200 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-100 text-slate-400 hover:text-blue-600 hover:bg-white hover:shadow-sm" title="Google Maps"><i data-lucide="map" class="w-5 h-5"></i></a>
${cleanPhone ? ` ${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="https://wa.me/34${cleanPhone}" target="_blank" class="action-btn p-2.5 rounded-xl bg-slate-100 text-slate-400 hover:text-emerald-600 hover:bg-white hover:shadow-sm" 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> <a href="tel:${cleanPhone}" class="action-btn p-2.5 rounded-xl bg-slate-100 text-slate-400 hover:text-blue-600 hover:bg-white hover:shadow-sm" title="Llamar"><i data-lucide="phone-call" class="w-5 h-5"></i></a>
` : ''} ` : ''}
</div> </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"> <button onclick="openEditor(${svc.id})" class="bg-blue-600 hover:bg-slate-900 text-white p-4 rounded-2xl shadow-lg transition-all active:scale-90" title="Editar e Importar">
<i data-lucide="edit-3" class="w-6 h-6"></i> <i data-lucide="edit-3" class="w-6 h-6"></i>
</button> </button>` : `
<div class="bg-slate-100 text-slate-400 p-4 rounded-2xl border-2 border-dashed" title="Servicio bloqueado por el proveedor">
<i data-lucide="shield-off" class="w-6 h-6"></i>
</div>`}
</div> </div>
`; `;
container.appendChild(card); container.appendChild(card);
@@ -210,27 +220,26 @@
const raw = svc.raw_data; const raw = svc.raw_data;
const myMap = mappings.filter(m => m.provider === svc.provider); const myMap = mappings.filter(m => m.provider === svc.provider);
// 1. LIMPIEZA DE TELÉFONO QUIRÚRGICA // 1. TELÉFONO LIMPIO
const phoneVal = raw[myMap.find(m => m.target_key === 'phone')?.original_key] || raw['Teléfono'] || ""; const phoneVal = raw[myMap.find(m => m.target_key === 'phone')?.original_key] || raw['Teléfono'] || "";
const phoneMatch = phoneVal.match(/[6789]\d{8}/); const phoneMatch = phoneVal.match(/[6789]\d{8}/);
document.getElementById('imp_phone').value = phoneMatch ? phoneMatch[0] : ""; document.getElementById('imp_phone').value = phoneMatch ? phoneMatch[0] : "";
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}` : ""; document.getElementById('imp_phone_extra').innerText = phoneVal !== (phoneMatch ? phoneMatch[0] : "") ? `Dato original capturado: ${phoneVal}` : "";
// 2. CONCATENACIÓN DIRECCIÓN + POBLACIÓN // 2. CP Y DIRECCIÓN + POBLACIÓN
const addr = raw[myMap.find(m => m.target_key === 'address')?.original_key] || ""; 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 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 cpVal = raw[myMap.find(m => m.target_key === 'cp')?.original_key] || raw['Población_CP'] || "";
const cpMatch = cpVal.match(/\b\d{5}\b/); const cpMatch = cpVal.match(/\b\d{5}\b/);
document.getElementById('imp_address').value = `${addr} ${pop}`.trim();
document.getElementById('imp_cp').value = cpMatch ? cpMatch[0] : ""; document.getElementById('imp_cp').value = cpMatch ? cpMatch[0] : "";
// 4. PROVEEDOR - COMPAÑÍA (Formato: ROBOT - COMPAÑÍA) // 3. PROVEEDOR ACORTADO EN COMPAÑÍA
const cia = raw[myMap.find(m => m.target_key === 'compania')?.original_key] || raw['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}`; const shortProv = svc.provider.toUpperCase() === 'MULTIASISTENCIA' ? 'MULTI' : 'HOME';
document.getElementById('imp_company').value = `${shortProv} - ${cia}`;
// 5. RESTO DE DATOS
document.getElementById('scrapedId').value = scrapedId; document.getElementById('scrapedId').value = scrapedId;
document.getElementById('imp_name').value = raw[myMap.find(m => m.target_key === 'clientName')?.original_key] || ""; document.getElementById('imp_name').value = raw[myMap.find(m => m.target_key === 'clientName')?.original_key] || "";
document.getElementById('imp_ref').value = svc.service_ref; document.getElementById('imp_ref').value = svc.service_ref;
@@ -246,8 +255,7 @@
async function handleImportSubmit(e) { async function handleImportSubmit(e) {
e.preventDefault(); e.preventDefault();
const btn = document.getElementById('btnImport'); const btn = document.getElementById('btnImport');
const originalText = btn.innerHTML; btn.disabled = true; btn.innerText = "PROCESANDO...";
btn.disabled = true; btn.innerText = "Procesando...";
const payload = { const payload = {
name: document.getElementById('imp_name').value, name: document.getElementById('imp_name').value,
@@ -265,12 +273,12 @@
body: JSON.stringify(payload) body: JSON.stringify(payload)
}); });
if(res.ok) { if(res.ok) {
showToast("✅ Importación completada."); showToast("✅ ¡Expediente importado con éxito!");
closeModal(); closeModal();
loadInbox(); loadInbox();
} else { showToast("No se pudo completar la importación.", true); } } else { showToast("Error al importar", true); }
} catch (e) { showToast("Error de conexión con el servidor.", true); } } catch (e) { showToast("Error de conexión", true); }
finally { btn.disabled = false; btn.innerHTML = originalText; lucide.createIcons(); } finally { btn.disabled = false; btn.innerText = "IMPORTAR A SERVICIOS"; }
} }
function showToast(msg, isError = false) { function showToast(msg, isError = false) {