Actualizar calendario.html
This commit is contained in:
@@ -591,7 +591,24 @@
|
||||
method: 'PUT', headers: { "Content-Type": "application/json", "Authorization": `Bearer ${localStorage.getItem("token")}` },
|
||||
body: JSON.stringify({ status_operativo: st.id })
|
||||
});
|
||||
if(res.ok) { showToast("¡Actualizado!"); closeModal(); refreshData(); }
|
||||
|
||||
if(res.ok) {
|
||||
showToast("¡Actualizado!");
|
||||
|
||||
// MAGIA: Si es "De camino", forzamos enviar el GPS INMEDIATAMENTE
|
||||
if (action === 'camino' && navigator.geolocation) {
|
||||
navigator.geolocation.getCurrentPosition(async (pos) => {
|
||||
await fetch(`${API_URL}/services/${currentServiceId}/location`, {
|
||||
method: 'POST',
|
||||
headers: { "Content-Type": "application/json", "Authorization": `Bearer ${localStorage.getItem("token")}` },
|
||||
body: JSON.stringify({ lat: pos.coords.latitude, lng: pos.coords.longitude })
|
||||
});
|
||||
}, () => {}, { enableHighAccuracy: false, timeout: 10000 });
|
||||
}
|
||||
|
||||
closeModal();
|
||||
refreshData();
|
||||
}
|
||||
} catch (e) { alert("Error"); }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user