summaryrefslogtreecommitdiff
path: root/iridescence/src/store/index.js
diff options
context:
space:
mode:
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) {