summaryrefslogtreecommitdiff
path: root/iridescence/src/store/index.js
diff options
context:
space:
mode:
authorAdam T. Carpenter <atc@53hor.net>2020-11-12 16:27:13 -0500
committerAdam T. Carpenter <atc@53hor.net>2020-11-12 16:27:13 -0500
commit9b77f9ec2c00b48c551f65b2e9d7a087004de4c0 (patch)
treeb7eb96fc4a2c7baffcb4acfc93c572ab079f11a2 /iridescence/src/store/index.js
parent7381a7033231e6454a37fd64b1f3de4e8d59355f (diff)
downloadtheglassyladies-9b77f9ec2c00b48c551f65b2e9d7a087004de4c0.tar.xz
theglassyladies-9b77f9ec2c00b48c551f65b2e9d7a087004de4c0.zip
Noice. Product creation and updating is totally functional.
Diffstat (limited to 'iridescence/src/store/index.js')
-rw-r--r--iridescence/src/store/index.js28
1 files changed, 6 insertions, 22 deletions
diff --git a/iridescence/src/store/index.js b/iridescence/src/store/index.js
index f98fd87..19205c9 100644
--- a/iridescence/src/store/index.js
+++ b/iridescence/src/store/index.js
@@ -41,22 +41,6 @@ export default new Vuex.Store({
if (products) {
state.products = products;
}
- },
- replaceProduct(state, product) {
- if (!product || !product.id) {
- return;
- }
-
- let index = state.products.findIndex(p => p.id == product.id);
-
- if (index) {
- state.products[index] = product;
- }
- },
- addProduct(state, product) {
- if (product) {
- state.products.push(product);
- }
}
},
actions: {
@@ -66,16 +50,16 @@ export default new Vuex.Store({
commit("setProducts", products);
commit("toggleBusy");
},
- async updateProduct({ commit }, product) {
+ async updateProduct({ commit, dispatch }, product) {
commit("toggleBusy");
- const updatedProduct = await dichroism.updateProduct(product);
- commit("replaceProduct", updatedProduct);
+ await dichroism.updateProduct(product);
+ dispatch("refreshProducts");
commit("toggleBusy");
},
- async createProduct({ commit }, product) {
+ async createProduct({ commit, dispatch }, product) {
commit("toggleBusy");
- const newProduct = await dichroism.createProduct(product);
- commit("addProduct", newProduct);
+ await dichroism.createProduct(product);
+ dispatch("refreshProducts");
commit("toggleBusy");
},
async createPhotoSet({ commit }, file) {