initial: bootstrap from BukidBountyApp base
This commit is contained in:
32
resources/js/stores/syncState.js
Normal file
32
resources/js/stores/syncState.js
Normal file
@@ -0,0 +1,32 @@
|
||||
// resources/js/stores/syncState.js
|
||||
import { defineStore } from 'pinia';
|
||||
import { ref } from 'vue';
|
||||
|
||||
export const useSyncStore = defineStore('sync', () => {
|
||||
const syncStatus = ref({}); // Maps keys to their sync status (e.g. { 'user': 'synced', 'leads': 'stale' })
|
||||
const lastSynced = ref({}); // Maps keys to their last sync timestamp
|
||||
const errors = ref({}); // Maps keys to any sync errors
|
||||
|
||||
const updateStatus = (key, status) => {
|
||||
syncStatus.value[key] = status;
|
||||
if (status === 'synced') {
|
||||
lastSynced.value[key] = new Date().toISOString();
|
||||
}
|
||||
};
|
||||
|
||||
const setError = (key, error) => {
|
||||
errors.value[key] = error;
|
||||
syncStatus.value[key] = 'failed';
|
||||
};
|
||||
|
||||
const getStatus = (key) => syncStatus.value[key] || 'pending';
|
||||
|
||||
return {
|
||||
syncStatus,
|
||||
lastSynced,
|
||||
errors,
|
||||
updateStatus,
|
||||
setError,
|
||||
getStatus
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user