From 9b77f9ec2c00b48c551f65b2e9d7a087004de4c0 Mon Sep 17 00:00:00 2001 From: "Adam T. Carpenter" Date: Thu, 12 Nov 2020 16:27:13 -0500 Subject: Noice. Product creation and updating is totally functional. --- iridescence/src/store/index.js | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) (limited to 'iridescence/src/store') 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) { -- cgit v1.2.3