summaryrefslogtreecommitdiff
path: root/iridescence/src/store
diff options
context:
space:
mode:
authorAdam T. Carpenter <atc@53hor.net>2020-11-23 17:29:58 -0500
committerAdam T. Carpenter <atc@53hor.net>2020-11-23 17:29:58 -0500
commit2e7da5ab02ffa8b07fede7f6cd7e5dbbd90fac5f (patch)
treef1d29c4e00174540821d3f8cd9e9b3d943f90f26 /iridescence/src/store
parent58c7f82c2cbf2f2ff3f5c2dd559e570924a41a4a (diff)
downloadtheglassyladies-2e7da5ab02ffa8b07fede7f6cd7e5dbbd90fac5f.tar.xz
theglassyladies-2e7da5ab02ffa8b07fede7f6cd7e5dbbd90fac5f.zip
finished up product detail functionality, started checkout and cart
views
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: {}
+ }
});