fix: layouts
This commit is contained in:
40
bo/src/stores/category.ts
Normal file
40
bo/src/stores/category.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { ref } from "vue";
|
||||
|
||||
|
||||
const products = [
|
||||
{name: "product name", price: 342432},
|
||||
{name: "product name", price: 342432},
|
||||
{name: "product name", price: 342432},
|
||||
{name: "product name", price: 342432},
|
||||
{name: "product name", price: 342432},
|
||||
]
|
||||
|
||||
// type CategoryProducts = {}
|
||||
|
||||
export const useCategoryStore = defineStore('category', () => {
|
||||
const id_category = ref(0)
|
||||
const categoryProducts = ref(products)
|
||||
|
||||
|
||||
function setCategoryID(id: number) {
|
||||
id_category.value = id
|
||||
}
|
||||
|
||||
async function getCategoryProducts() {
|
||||
return new Promise<typeof products>((resolve) => {
|
||||
setTimeout(() => {
|
||||
console.log('Fetching products from category id: ', id_category.value);
|
||||
resolve(categoryProducts.value)
|
||||
}, 2000 * Math.random())
|
||||
})
|
||||
}
|
||||
return {
|
||||
id_category,
|
||||
getCategoryProducts,
|
||||
setCategoryID
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user