Actualizar servicios.html
This commit is contained in:
@@ -731,11 +731,10 @@
|
||||
setTimeout(() => { toast.classList.add('hidden'); }, 3500);
|
||||
}
|
||||
|
||||
// LA FUNCIÓN CORREGIDA
|
||||
function openDetail(id, startInEditMode = false) {
|
||||
const s = localData.find(x => x.id === id);
|
||||
if (!s) return;
|
||||
const raw = s.raw_data || {}; // Seguridad anti-crashes
|
||||
const raw = s.raw_data || {};
|
||||
|
||||
document.getElementById('detId').value = s.id;
|
||||
document.getElementById('detRef').innerText = s.service_ref || "";
|
||||
@@ -744,7 +743,6 @@
|
||||
const companyName = raw['Compañía'] || raw['COMPAÑIA'] || raw['Procedencia'] || "Particular";
|
||||
if (document.getElementById('detCompany')) document.getElementById('detCompany').innerText = companyName;
|
||||
|
||||
// RELLENADO DE CAMPOS PARA EL EDITOR Y VISTA (Inputs)
|
||||
const clientName = raw["Nombre Cliente"] || raw["CLIENTE"] || "Asegurado Sin Nombre";
|
||||
if(document.getElementById('editName')) document.getElementById('editName').value = clientName;
|
||||
|
||||
@@ -753,7 +751,6 @@
|
||||
const singlePhone = matchPhone ? matchPhone[0] : "";
|
||||
if(document.getElementById('editPhone')) document.getElementById('editPhone').value = singlePhone;
|
||||
|
||||
// Lógica del botón de llamada dinámico
|
||||
const callBtn = document.getElementById('btnCallPhone');
|
||||
if (callBtn) {
|
||||
if (singlePhone) {
|
||||
@@ -808,7 +805,8 @@
|
||||
} else {
|
||||
cancelEditing();
|
||||
}
|
||||
loadChat(id);
|
||||
|
||||
loadChat(id); // <---- ESTO ES LO QUE FALTABA
|
||||
lucide.createIcons();
|
||||
}
|
||||
|
||||
@@ -1018,7 +1016,6 @@
|
||||
}
|
||||
|
||||
async function copyClientPortalLink() {
|
||||
// CORRECCIÓN: Leemos los datos desde los inputs usando .value
|
||||
const phone = document.getElementById('editPhone').value;
|
||||
const name = document.getElementById('editName').value;
|
||||
const addr = document.getElementById('editAddr').value;
|
||||
@@ -1037,7 +1034,6 @@
|
||||
lucide.createIcons();
|
||||
|
||||
try {
|
||||
// Limpiamos el teléfono de espacios para evitar fallos
|
||||
const cleanPhone = phone.replace(/\D/g, "");
|
||||
|
||||
const res = await fetch(`${API_URL}/clients/ensure`, {
|
||||
@@ -1054,7 +1050,6 @@
|
||||
|
||||
const portalLink = `https://portal.integrarepara.es/?token=${data.client.portal_token}&service=${serviceId}`;
|
||||
|
||||
// Doble seguro para copiar (el navegador a veces bloquea navigator.clipboard si no hay HTTPS o permiso explícito)
|
||||
try {
|
||||
await navigator.clipboard.writeText(portalLink);
|
||||
showToast("✅ Enlace copiado al portapapeles.");
|
||||
@@ -1106,7 +1101,6 @@
|
||||
} catch (e) { console.error("Error en buscador rápido:", e); }
|
||||
}
|
||||
|
||||
// --- MOTOR DE EDICIÓN DE FICHA ---
|
||||
function enableEditing() {
|
||||
document.getElementById('viewActions').classList.add('hidden');
|
||||
document.getElementById('editActions').classList.remove('hidden');
|
||||
@@ -1201,7 +1195,6 @@
|
||||
chatBox.innerHTML += bubbleHtml;
|
||||
});
|
||||
|
||||
// Hacer scroll hasta abajo automáticamente
|
||||
setTimeout(() => { chatBox.scrollTop = chatBox.scrollHeight; }, 100);
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -1228,7 +1221,7 @@
|
||||
if (res.ok) {
|
||||
input.value = '';
|
||||
document.getElementById('chatInternal').checked = false;
|
||||
loadChat(serviceId); // Recargar el chat al enviar
|
||||
loadChat(serviceId);
|
||||
} else {
|
||||
showToast("Error al enviar mensaje", "warning");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user