Actualizar calendario.html
This commit is contained in:
@@ -528,9 +528,32 @@
|
|||||||
setTimeout(() => modal.style.display = 'none', 300);
|
setTimeout(() => modal.style.display = 'none', 300);
|
||||||
}
|
}
|
||||||
|
|
||||||
function callClient() { const p = document.getElementById('detPhoneRaw').value; if (p) window.location.href = `tel:+34${p}`; else alert("Sin teléfono"); }
|
// --- FUNCIÓN SECRETA DE LOGS ---
|
||||||
function openWhatsApp() { const p = document.getElementById('detPhoneRaw').value; if (p) window.open(`https://wa.me/34${p}`, '_blank'); else alert("Sin teléfono"); }
|
function sendLog(action, details) {
|
||||||
|
if(!currentServiceId) return;
|
||||||
|
fetch(`${API_URL}/services/${currentServiceId}/log`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { "Content-Type": "application/json", "Authorization": `Bearer ${localStorage.getItem("token")}` },
|
||||||
|
body: JSON.stringify({ action, details })
|
||||||
|
}).catch(()=>{}); // Si falla, que no rompa la app, es un log silencioso
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- BOTONES MODIFICADOS ---
|
||||||
|
function callClient() {
|
||||||
|
const p = document.getElementById('detPhoneRaw').value;
|
||||||
|
if (p) {
|
||||||
|
sendLog("Llamada Telefónica", "El operario ha pulsado el botón de llamar al cliente.");
|
||||||
|
window.location.href = `tel:+34${p}`;
|
||||||
|
} else { alert("Sin teléfono"); }
|
||||||
|
}
|
||||||
|
|
||||||
|
function openWhatsApp() {
|
||||||
|
const p = document.getElementById('detPhoneRaw').value;
|
||||||
|
if (p) {
|
||||||
|
sendLog("WhatsApp Abierto", "El operario ha abierto el chat de WhatsApp con el cliente.");
|
||||||
|
window.open(`https://wa.me/34${p}`, '_blank');
|
||||||
|
} else { alert("Sin teléfono"); }
|
||||||
|
}
|
||||||
|
|
||||||
async function copyAndOpenPortal() {
|
async function copyAndOpenPortal() {
|
||||||
const btn = document.getElementById('btnPortal');
|
const btn = document.getElementById('btnPortal');
|
||||||
@@ -548,7 +571,6 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Usamos la API que ya tienes para obtener el token mágico del cliente
|
|
||||||
const res = await fetch(`${API_URL}/clients/ensure`, {
|
const res = await fetch(`${API_URL}/clients/ensure`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${localStorage.getItem("token")}` },
|
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${localStorage.getItem("token")}` },
|
||||||
@@ -559,7 +581,6 @@
|
|||||||
if (data.ok && data.client.portal_token) {
|
if (data.ok && data.client.portal_token) {
|
||||||
const link = `https://portal.integrarepara.es/?token=${data.client.portal_token}&service=${currentServiceId}`;
|
const link = `https://portal.integrarepara.es/?token=${data.client.portal_token}&service=${currentServiceId}`;
|
||||||
|
|
||||||
// Intentamos copiar al portapapeles
|
|
||||||
try {
|
try {
|
||||||
await navigator.clipboard.writeText(link);
|
await navigator.clipboard.writeText(link);
|
||||||
showToast("¡Enlace copiado al portapapeles!");
|
showToast("¡Enlace copiado al portapapeles!");
|
||||||
@@ -567,7 +588,7 @@
|
|||||||
console.warn("Navegador bloqueó el copiado automático");
|
console.warn("Navegador bloqueó el copiado automático");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Y lo abrimos inmediatamente en otra pestaña
|
sendLog("Portal Generado", "El operario ha generado y abierto el enlace al Portal del Cliente.");
|
||||||
window.open(link, '_blank');
|
window.open(link, '_blank');
|
||||||
} else {
|
} else {
|
||||||
showToast("Error al obtener el enlace", true);
|
showToast("Error al obtener el enlace", true);
|
||||||
|
|||||||
Reference in New Issue
Block a user