Actualizar calendario.html
This commit is contained in:
@@ -126,8 +126,11 @@
|
|||||||
<p class="text-[9px] font-black text-primary-dynamic uppercase tracking-widest" id="detCompany">Compañía</p>
|
<p class="text-[9px] font-black text-primary-dynamic uppercase tracking-widest" id="detCompany">Compañía</p>
|
||||||
<span id="detRef" class="text-[9px] font-black text-slate-400 uppercase"></span>
|
<span id="detRef" class="text-[9px] font-black text-slate-400 uppercase"></span>
|
||||||
</div>
|
</div>
|
||||||
<h2 id="detName" class="text-2xl font-black text-slate-900 uppercase leading-none mb-6">Nombre Cliente</h2>
|
<h2 id="detName" class="text-2xl font-black text-slate-900 uppercase leading-none mb-3">Nombre Cliente</h2>
|
||||||
|
|
||||||
|
<button onclick="copyAndOpenPortal()" id="btnPortal" class="w-full mb-6 bg-indigo-50 text-indigo-700 hover:bg-indigo-100 font-black py-2.5 rounded-xl border border-indigo-200 flex items-center justify-center gap-2 text-[10px] uppercase tracking-widest active:scale-95 transition-all text-center">
|
||||||
|
<i data-lucide="external-link" class="w-4 h-4"></i> Copiar y Abrir Portal
|
||||||
|
</button>
|
||||||
<button onclick="callClient()" class="w-full bg-primary-dynamic text-white font-black py-4 rounded-2xl shadow-xl flex items-center justify-center gap-3 uppercase text-sm tracking-widest active:scale-95 transition-all">
|
<button onclick="callClient()" class="w-full bg-primary-dynamic text-white font-black py-4 rounded-2xl shadow-xl flex items-center justify-center gap-3 uppercase text-sm tracking-widest active:scale-95 transition-all">
|
||||||
<i data-lucide="phone" class="w-5 h-5 fill-current"></i> Llamar al Cliente
|
<i data-lucide="phone" class="w-5 h-5 fill-current"></i> Llamar al Cliente
|
||||||
</button>
|
</button>
|
||||||
@@ -528,6 +531,54 @@
|
|||||||
function callClient() { const p = document.getElementById('detPhoneRaw').value; if (p) window.location.href = `tel:+34${p}`; else alert("Sin teléfono"); }
|
function callClient() { const p = document.getElementById('detPhoneRaw').value; if (p) window.location.href = `tel:+34${p}`; else alert("Sin teléfono"); }
|
||||||
function openWhatsApp() { const p = document.getElementById('detPhoneRaw').value; if (p) window.open(`https://wa.me/34${p}`, '_blank'); else alert("Sin teléfono"); }
|
function openWhatsApp() { const p = document.getElementById('detPhoneRaw').value; if (p) window.open(`https://wa.me/34${p}`, '_blank'); else alert("Sin teléfono"); }
|
||||||
|
|
||||||
|
|
||||||
|
async function copyAndOpenPortal() {
|
||||||
|
const btn = document.getElementById('btnPortal');
|
||||||
|
const originalHtml = btn.innerHTML;
|
||||||
|
btn.innerHTML = '<i data-lucide="loader-2" class="w-4 h-4 animate-spin"></i> Generando...';
|
||||||
|
lucide.createIcons();
|
||||||
|
|
||||||
|
try {
|
||||||
|
const phone = document.getElementById('detPhoneRaw').value;
|
||||||
|
const name = document.getElementById('detName').innerText;
|
||||||
|
const address = document.getElementById('detAddress').innerText;
|
||||||
|
|
||||||
|
if (!phone) {
|
||||||
|
showToast("Sin teléfono no hay portal", true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Usamos la API que ya tienes para obtener el token mágico del cliente
|
||||||
|
const res = await fetch(`${API_URL}/clients/ensure`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${localStorage.getItem("token")}` },
|
||||||
|
body: JSON.stringify({ phone, name, address })
|
||||||
|
});
|
||||||
|
const data = await res.json();
|
||||||
|
|
||||||
|
if (data.ok && data.client.portal_token) {
|
||||||
|
const link = `https://portal.integrarepara.es/?token=${data.client.portal_token}&service=${currentServiceId}`;
|
||||||
|
|
||||||
|
// Intentamos copiar al portapapeles
|
||||||
|
try {
|
||||||
|
await navigator.clipboard.writeText(link);
|
||||||
|
showToast("¡Enlace copiado al portapapeles!");
|
||||||
|
} catch (err) {
|
||||||
|
console.warn("Navegador bloqueó el copiado automático");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Y lo abrimos inmediatamente en otra pestaña
|
||||||
|
window.open(link, '_blank');
|
||||||
|
} else {
|
||||||
|
showToast("Error al obtener el enlace", true);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
showToast("Error de conexión", true);
|
||||||
|
} finally {
|
||||||
|
btn.innerHTML = originalHtml;
|
||||||
|
lucide.createIcons();
|
||||||
|
}
|
||||||
|
}
|
||||||
function openMaps() {
|
function openMaps() {
|
||||||
const a = document.getElementById('detAddress').innerText;
|
const a = document.getElementById('detAddress').innerText;
|
||||||
if (a) {
|
if (a) {
|
||||||
|
|||||||
Reference in New Issue
Block a user