feat: product options, speedup home page, themes
This commit is contained in:
25
spa/src/stores/CategoriesStore.js
Normal file
25
spa/src/stores/CategoriesStore.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import {defineStore} from "pinia";
|
||||
import ftch from "../utils/ftch.js";
|
||||
|
||||
export const useCategoriesStore = defineStore('categories', {
|
||||
state: () => ({
|
||||
topCategories: [],
|
||||
isLoading: false,
|
||||
}),
|
||||
|
||||
actions: {
|
||||
async fetchTopCategories() {
|
||||
try {
|
||||
this.isLoading = true;
|
||||
const response = await ftch('categoriesList', {
|
||||
perPage: 7,
|
||||
});
|
||||
this.topCategories = response.data;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
this.isLoading = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
25
spa/src/stores/ProductsStore.js
Normal file
25
spa/src/stores/ProductsStore.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import {defineStore} from "pinia";
|
||||
import ftch from "../utils/ftch.js";
|
||||
|
||||
export const useProductsStore = defineStore('products', {
|
||||
state: () => ({
|
||||
homeProducts: {
|
||||
data: [],
|
||||
meta: {},
|
||||
},
|
||||
isLoading: false,
|
||||
}),
|
||||
|
||||
actions: {
|
||||
async fetchHomeProducts() {
|
||||
try {
|
||||
this.isLoading = true;
|
||||
this.homeProducts = await ftch('products');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
this.isLoading = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user