+
-
@@ -49,10 +49,10 @@
@@ -34,9 +34,9 @@ Buzón de Automatizaciones
-Validación rápida de expedientes externos.
+Gestiona e importa los avisos capturados por los robots.
-
+
@@ -64,46 +64,43 @@
- Validar Importación + Revisar Datos
-
-
+
+
-
-
+
+
-
-
-
-
-
+
+
-
+
-
+
-
-
-
+
`;
lucide.createIcons();
return;
@@ -157,45 +154,58 @@
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] || "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 ubicación";
+ // Extracción de datos
+ const rawName = raw[myMap.find(m => m.target_key === 'clientName')?.original_key] || "";
+ const rawAddr = raw[myMap.find(m => m.target_key === 'address')?.original_key] || "";
+ 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 cleanPhone = rawPhone.match(/[6789]\d{8}/) ? rawPhone.match(/[6789]\d{8}/)[0] : "";
- // Acortar nombre de proveedor
- const shortProv = svc.provider.toUpperCase().replace('MULTIASISTENCIA', 'MULTI');
+ // Lógica de Bloqueo (Candado)
+ const isBlocked = (!rawName || rawName.toLowerCase().includes('expediente sin nombre') || !rawAddr);
+ const shortProv = svc.provider === 'multiasistencia' ? 'MULTI' : 'HOME';
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 = `
+ ${isBlocked ? '' : ``}
+
+
+
-
-
-
+
- CREAR SERVICIO EN CRM
+
+ Importar a Servicios
@@ -145,8 +142,8 @@
if(scrapedData.length === 0) {
container.innerHTML = `
+
+
-
-
+
-
+
-
¡Todo al día!
-No hay nuevos expedientes externos para procesar.
+Buzón al día
+No hay nuevos expedientes para validar.
-
+
+
${shortProv}
-
+
-
` : ''}
${name}
-${fullAddr}
+${isBlocked ? 'Expediente Bloqueado en Compañía' : (rawName || 'Nombre no detectado')}
++ ${isBlocked ? 'Pendiente de liberación de datos' : (fullAddr || 'Sin dirección')} +
+ ${!isBlocked ? `
#${svc.service_ref}
${cleanPhone ? `${cleanPhone}` : ''}
-
+
-
`;
container.appendChild(card);
@@ -210,27 +220,26 @@
const raw = svc.raw_data;
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 phoneMatch = phoneVal.match(/[6789]\d{8}/);
document.getElementById('imp_phone').value = phoneMatch ? phoneMatch[0] : "";
- document.getElementById('imp_phone_extra').innerHTML = phoneVal !== (phoneMatch ? phoneMatch[0] : "") ? `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 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] : "";
- // 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'] || "";
- 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('imp_name').value = raw[myMap.find(m => m.target_key === 'clientName')?.original_key] || "";
document.getElementById('imp_ref').value = svc.service_ref;
@@ -246,8 +255,7 @@
async function handleImportSubmit(e) {
e.preventDefault();
const btn = document.getElementById('btnImport');
- const originalText = btn.innerHTML;
- btn.disabled = true; btn.innerText = "Procesando...";
+ btn.disabled = true; btn.innerText = "PROCESANDO...";
const payload = {
name: document.getElementById('imp_name').value,
@@ -265,12 +273,12 @@
body: JSON.stringify(payload)
});
if(res.ok) {
- showToast("✅ Importación completada.");
+ showToast("✅ ¡Expediente importado con éxito!");
closeModal();
loadInbox();
- } 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(); }
+ } else { showToast("Error al importar", true); }
+ } catch (e) { showToast("Error de conexión", true); }
+ finally { btn.disabled = false; btn.innerText = "IMPORTAR A SERVICIOS"; }
}
function showToast(msg, isError = false) {