Actualizar calendario.html
This commit is contained in:
@@ -650,9 +650,35 @@
|
||||
safeLoadIcons();
|
||||
}
|
||||
|
||||
function openService(id) {
|
||||
const s = localServices.find(x => x.id === id);
|
||||
if (!s || s.provider === 'SYSTEM_BLOCK') return;
|
||||
async function openService(id) {
|
||||
let s = localServices.find(x => x.id === id);
|
||||
|
||||
// 🔥 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;
|
||||
currentServiceId = id;
|
||||
|
||||
@@ -701,11 +727,20 @@
|
||||
setTimeout(() => modal.classList.remove('translate-y-full'), 10);
|
||||
calculateDistance(fullAddress);
|
||||
|
||||
// Cerrar chat al abrir otro servicio
|
||||
// 🔥 MEJORA: Al abrir desde notificación, abrimos el chat automáticamente
|
||||
if (activeNotifications.includes(id)) {
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
function closeModal() {
|
||||
|
||||
Reference in New Issue
Block a user