first commit

This commit is contained in:
thomas
2019-09-30 19:48:54 +02:00
parent 180348b4d4
commit f575b5b70b
10 changed files with 182 additions and 115 deletions
+22
View File
@@ -0,0 +1,22 @@
export const state = () => ({
products: [],
cart: []
})
export const mutations = {
setProducts (state, data) {
state.products = data
},
addToCart (state, item) {
const element = state.cart.filter(el => el.id === item.id)
if (element.length > 0) {
const index = state.cart.indexOf(element[0])
// eslint-disable-next-line no-console
console.log(index)
state.cart[index].count++
} else {
item.count = 1
state.cart.push(item)
}
}
}