Refactor layout components and add loading state
- Refactor the layout components to improve code organization and readability. - Add a new store called LoadingStore to manage the loading state. - Update AppLayout.vue, AppMenu.vue, AppTopbar.vue, ScenarioStore.js, and UserPrefStore.js to import and use the LoadingStore. - Add loading indicators in AppTopbar.vue and ScenarioList.vue components.
This commit is contained in:
@@ -1,19 +1,24 @@
|
||||
import { useAuth } from '@websanova/vue-auth/src/v3.js';
|
||||
import { defineStore } from 'pinia';
|
||||
import { computed, ref } from 'vue';
|
||||
import { LoadingStore } from './LoadingStore';
|
||||
|
||||
export const UserPrefStore = defineStore('userpref_store', () => {
|
||||
|
||||
const user = ref(null)
|
||||
const userLoaded = ref(false)
|
||||
const selectedApp = ref(null)
|
||||
const loadingStore = LoadingStore()
|
||||
|
||||
|
||||
async function fetchUserData(){
|
||||
|
||||
const auth = useAuth();
|
||||
|
||||
loadingStore.user_loading = true;
|
||||
await auth.fetch().then((fetchedUser) => {
|
||||
user.value = fetchedUser.data.data;
|
||||
userLoaded.value = true;
|
||||
loadingStore.user_loading = false;
|
||||
}).catch((error) => {
|
||||
reject(error);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user