Files
anahita-front/stores/products.js
T
mohadese namavar ec84dfd222 init git
2024-06-16 00:22:14 +04:30

38 lines
1.1 KiB
JavaScript

export const useProductsStore = defineStore('products', {
state: () => {
return {
items: [],
item: null,
filters: {},
pages: 0
}
},
actions: {
async addReminder(id, form) {
const result = await useFetch(`/api/products/reminder/${id}`, {
headers: { Authorization: useCookie('token') }, method: 'put', body: form
})
return result;
},
async addReport(id, form) {
const body = {
items: Object.keys(form.items),
content: form.content
}
const result = await useFetch(`/api/products/reports/${id}`, {
headers: { Authorization: useCookie('token') }, method: 'post', body
})
return result;
},
async compareSearch(ids, query = "") {
const { status, data } = await useFetch(`/api/products/comparison/${ids.join('-')}/search?q=${query}`)
if (status.value == 'success') {
this.items = data.value
}
},
}
})