diff options
author | Adam T. Carpenter <atc@53hor.net> | 2020-11-12 16:27:13 -0500 |
---|---|---|
committer | Adam T. Carpenter <atc@53hor.net> | 2020-11-12 16:27:13 -0500 |
commit | 9b77f9ec2c00b48c551f65b2e9d7a087004de4c0 (patch) | |
tree | b7eb96fc4a2c7baffcb4acfc93c572ab079f11a2 /iridescence/src/store | |
parent | 7381a7033231e6454a37fd64b1f3de4e8d59355f (diff) | |
download | theglassyladies-9b77f9ec2c00b48c551f65b2e9d7a087004de4c0.tar.xz theglassyladies-9b77f9ec2c00b48c551f65b2e9d7a087004de4c0.zip |
Noice. Product creation and updating is totally functional.
Diffstat (limited to 'iridescence/src/store')
-rw-r--r-- | iridescence/src/store/index.js | 28 |
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) { |