Add files via upload
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
import axios from '../plugins/axios'
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export const useDiscountStore = defineStore('discounts', {
|
||||
state: () => ({
|
||||
items: [],
|
||||
brands: [],
|
||||
categories: [],
|
||||
fetching: true,
|
||||
total: 0
|
||||
}),
|
||||
actions: {
|
||||
async index() {
|
||||
this.items = [];
|
||||
this.fetching = true
|
||||
const { status, data } = await axios.get('/admins/discount')
|
||||
this.fetching = false
|
||||
return this.items = data
|
||||
|
||||
},
|
||||
async getDiscount(id) {
|
||||
this.items = [];
|
||||
this.fetching = true
|
||||
const { status, data } = await axios.get(`/admins/discount/${id}`)
|
||||
this.fetching = false
|
||||
return this.items = data
|
||||
|
||||
},
|
||||
// async create(newCourse) {
|
||||
// const { status, data } = await axios.post('/course', newCourse)
|
||||
|
||||
// return data
|
||||
|
||||
// },
|
||||
// async delete(id) {
|
||||
// const { status, data } = await axios.delete(`/course/${id}`, id)
|
||||
|
||||
// return data
|
||||
|
||||
// },
|
||||
|
||||
// async edit(id) {
|
||||
// const { status, data } = await axios.get(`/course/${id}`)
|
||||
// return data
|
||||
|
||||
// },
|
||||
|
||||
|
||||
|
||||
// async store(form) {
|
||||
// const result = await axios.post('/admin/products/add', form)
|
||||
|
||||
// if (result.status === 201)
|
||||
// this.items.unshift(result.data)
|
||||
|
||||
// return result;
|
||||
// },
|
||||
// async update(id, form) {
|
||||
// const result = await axios.put(`/admin/products/${id}`, form)
|
||||
|
||||
// if (result.status === 200) {
|
||||
// const index = this.items.findIndex(({ _id }) => _id == id)
|
||||
// this.items[index] = result.data
|
||||
// }
|
||||
|
||||
// return result;
|
||||
// },
|
||||
// async confirm(id, form) {
|
||||
// const result = await axios.post(`/admin/products/confirm/${id}`, form)
|
||||
|
||||
// if (result.status === 200) {
|
||||
// const index = this.items.findIndex(({ _id }) => _id == id)
|
||||
// this.items[index] = result.data
|
||||
// }
|
||||
|
||||
// return result;
|
||||
// },
|
||||
// async remove(id) {
|
||||
// const result = await axios.delete(`/admin/products/${id}`)
|
||||
|
||||
// if (result.status === 200) {
|
||||
// const index = this.items.findIndex(({ _id }) => _id == id)
|
||||
// this.items.splice(index, 1)
|
||||
// }
|
||||
|
||||
// return result;
|
||||
// },
|
||||
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user