Actualizar calendario.html
This commit is contained in:
@@ -650,9 +650,35 @@
|
|||||||
safeLoadIcons();
|
safeLoadIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
function openService(id) {
|
async function openService(id) {
|
||||||
const s = localServices.find(x => x.id === id);
|
let s = localServices.find(x => x.id === id);
|
||||||
if (!s || s.provider === 'SYSTEM_BLOCK') return;
|
|
||||||
|
// 🔥 SOLUCIÓN: Si no lo encontramos en memoria, lo pedimos al servidor
|
||||||
|
if (!s) {
|
||||||
|
showToast("Cargando expediente...");
|
||||||
|
try {
|
||||||
|
const res = await fetch(`${API_URL}/services/active`, {
|
||||||
|
headers: { "Authorization": `Bearer ${localStorage.getItem("token")}` }
|
||||||
|
});
|
||||||
|
const data = await res.json();
|
||||||
|
if (data.ok) {
|
||||||
|
// Lo buscamos en la base de datos completa de servicios activos
|
||||||
|
s = data.services.find(x => x.id === id);
|
||||||
|
if (s) {
|
||||||
|
// Lo añadimos a la memoria local para que funcione bien el modal
|
||||||
|
localServices.push(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Error buscando servicio fantasma:", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!s || s.provider === 'SYSTEM_BLOCK') {
|
||||||
|
showToast("No se pudo cargar el expediente", true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const raw = s.raw_data;
|
const raw = s.raw_data;
|
||||||
currentServiceId = id;
|
currentServiceId = id;
|
||||||
|
|
||||||
@@ -701,11 +727,20 @@
|
|||||||
setTimeout(() => modal.classList.remove('translate-y-full'), 10);
|
setTimeout(() => modal.classList.remove('translate-y-full'), 10);
|
||||||
calculateDistance(fullAddress);
|
calculateDistance(fullAddress);
|
||||||
|
|
||||||
// Cerrar chat al abrir otro servicio
|
// 🔥 MEJORA: Al abrir desde notificación, abrimos el chat automáticamente
|
||||||
document.getElementById('chatContainer').classList.add('hidden');
|
if (activeNotifications.includes(id)) {
|
||||||
document.getElementById('chatChevron').classList.remove('rotate-180');
|
document.getElementById('chatContainer').classList.remove('hidden');
|
||||||
|
document.getElementById('chatContainer').classList.add('flex');
|
||||||
|
document.getElementById('chatChevron').classList.add('rotate-180');
|
||||||
|
loadChat(id);
|
||||||
|
} else {
|
||||||
|
document.getElementById('chatContainer').classList.add('hidden');
|
||||||
|
document.getElementById('chatContainer').classList.remove('flex');
|
||||||
|
document.getElementById('chatChevron').classList.remove('rotate-180');
|
||||||
|
}
|
||||||
|
|
||||||
safeLoadIcons();
|
safeLoadIcons();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeModal() {
|
function closeModal() {
|
||||||
|
|||||||
Reference in New Issue
Block a user