From 9191a81a3ddc52bfe9c60f128726fc7a27c95810 Mon Sep 17 00:00:00 2001 From: R-Sourabh Date: Wed, 20 Nov 2024 10:53:15 +0530 Subject: [PATCH] Improved: Refactored removeStoreFromFacility to add error handling for updateFacility(#304) --- src/components/ProductStorePopover.vue | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/ProductStorePopover.vue b/src/components/ProductStorePopover.vue index 85b535f..0d372f9 100644 --- a/src/components/ProductStorePopover.vue +++ b/src/components/ProductStorePopover.vue @@ -71,11 +71,15 @@ export default defineComponent({ // TODO: need to check if we need to remove primary value from the facility if product store is removed. // Removing primaryFacilityGroupId from the facility, if present if(this.shopifyShopIdForProductStore(this.currentProductStore.productStoreId) === this.current.primaryFacilityGroupId) { - await FacilityService.updateFacility({ + const updateResp = await FacilityService.updateFacility({ facilityId: this.facilityId, primaryFacilityGroupId: '' - }) - await this.store.dispatch('facility/updateCurrentFacility', { ...this.current, primaryFacilityGroupId: '' }) + }); + if (!hasError(updateResp)) { + await this.store.dispatch('facility/updateCurrentFacility', { ...this.current, primaryFacilityGroupId: '' }); + } else { + throw updateResp.data; + } } // refetching product stores with updated roles await this.store.dispatch('facility/getFacilityProductStores', { facilityId: this.facilityId })