diff --git a/frontend/src/components/orders/OrderLineForm.vue b/frontend/src/components/orders/OrderLineForm.vue new file mode 100644 index 0000000..84bd742 --- /dev/null +++ b/frontend/src/components/orders/OrderLineForm.vue @@ -0,0 +1,132 @@ + + + diff --git a/frontend/src/components/vehicles/VehiclePicker.vue b/frontend/src/components/vehicles/VehiclePicker.vue new file mode 100644 index 0000000..b4542b5 --- /dev/null +++ b/frontend/src/components/vehicles/VehiclePicker.vue @@ -0,0 +1,108 @@ + + + diff --git a/frontend/src/composables/useSync.js b/frontend/src/composables/useSync.js new file mode 100644 index 0000000..f2897e9 --- /dev/null +++ b/frontend/src/composables/useSync.js @@ -0,0 +1,29 @@ +import { onMounted, onUnmounted } from 'vue' +import { syncEngine } from '../db/sync.js' +import { useAuthStore } from '../stores/auth.js' + +export function useSync() { + const auth = useAuthStore() + let interval = null + + function onFocus() { + if (auth.isAuthenticated && syncEngine.online) { + syncEngine.incrementalSync() + } + } + + onMounted(() => { + window.addEventListener('focus', onFocus) + // Periodic sync every 60s + interval = setInterval(() => { + if (auth.isAuthenticated && syncEngine.online) { + syncEngine.incrementalSync() + } + }, 60000) + }) + + onUnmounted(() => { + window.removeEventListener('focus', onFocus) + if (interval) clearInterval(interval) + }) +} diff --git a/frontend/src/layouts/AppLayout.vue b/frontend/src/layouts/AppLayout.vue index ac03d1e..985c67d 100644 --- a/frontend/src/layouts/AppLayout.vue +++ b/frontend/src/layouts/AppLayout.vue @@ -1,10 +1,23 @@