summaryrefslogtreecommitdiff
path: root/iridescence/src/store
diff options
context:
space:
mode:
Diffstat (limited to 'iridescence/src/store')
-rw-r--r--iridescence/src/store/index.js24
1 files changed, 16 insertions, 8 deletions
diff --git a/iridescence/src/store/index.js b/iridescence/src/store/index.js
index dabcf31..8208f35 100644
--- a/iridescence/src/store/index.js
+++ b/iridescence/src/store/index.js
@@ -10,17 +10,12 @@ export default new Vuex.Store({
state: {
searchTerm: "",
products: [],
+ cart: {},
busy: false,
compare: a => (a.featured ? -1 : 1),
productDetailId: 0
},
getters: {
- busy(state) {
- return state.busy;
- },
- productDetailId(state) {
- return state.productDetailId;
- },
products(state) {
return state.products
.filter(item => {
@@ -38,6 +33,20 @@ export default new Vuex.Store({
productDetailId(state, id) {
state.productDetailId = id;
},
+ cartItem(state, { id, by }) {
+ if (state.cart[id]) {
+ let newCount = (state.cart[id] += by);
+ state.cart = {
+ ...state.cart,
+ [id]: newCount
+ };
+ } else {
+ state.cart = {
+ ...state.cart,
+ [id]: 1
+ };
+ }
+ },
compare(state, compare) {
state.compare = compare;
},
@@ -75,6 +84,5 @@ export default new Vuex.Store({
commit("toggleBusy");
return photoSet;
}
- },
- modules: {}
+ }
});