diff --git a/spa/src/main.js b/spa/src/main.js index 721a5e6..e2ce32a 100644 --- a/spa/src/main.js +++ b/spa/src/main.js @@ -52,7 +52,6 @@ settings.load() console.log('Load front page categories and products.'); const categoriesStore = useCategoriesStore(); categoriesStore.fetchTopCategories(); - categoriesStore.fetchCategories(); }) .then(() => new AppMetaInitializer(settings).init()) .then(() => { appLoading.unmount(); app.mount('#app'); }) diff --git a/spa/src/stores/CategoriesStore.js b/spa/src/stores/CategoriesStore.js index caa6f45..3c7ed72 100644 --- a/spa/src/stores/CategoriesStore.js +++ b/spa/src/stores/CategoriesStore.js @@ -6,15 +6,17 @@ export const useCategoriesStore = defineStore('categories', { topCategories: [], categories: [], isLoading: false, + isCategoriesLoaded: false, }), actions: { async fetchCategories() { - if (this.isLoading === false && this.categories.length === 0) { + if (this.isCategoriesLoaded === false && this.categories.length === 0) { try { this.isLoading = true; const {data} = await ftch('categoriesList'); this.categories = data; + this.isCategoriesLoaded = true; } catch (error) { console.error(error); } finally { diff --git a/spa/src/views/CategoriesList.vue b/spa/src/views/CategoriesList.vue index 2e32b60..dfdaffc 100644 --- a/spa/src/views/CategoriesList.vue +++ b/spa/src/views/CategoriesList.vue @@ -2,32 +2,42 @@