Initial commit - construprogress app

This commit is contained in:
2026-05-07 23:31:33 +02:00
commit 156aa14bbb
157 changed files with 21654 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
import './bootstrap';
import localforage from 'localforage';
// Sync pending actions when online
window.addEventListener('online', () => {
fetch('/offline/sync', { method: 'POST', headers: { 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content } })
.then(res => res.json())
.then(data => console.log('Synced:', data));
});
// Function to store offline progress update
window.offlineProgressUpdate = function(phaseId, progress, comment, location) {
const payload = { phase_id: phaseId, progress, comment, location };
if (navigator.onLine) {
fetch('/offline/pending', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content },
body: JSON.stringify({ action: 'progress_update', payload })
}).then(() => alert('Actualizado online'));
} else {
localforage.getItem('pendingOffline').then(pending => {
const list = pending || [];
list.push(payload);
localforage.setItem('pendingOffline', list);
alert('Guardado localmente, se sincronizará al recuperar internet');
});
}
};