Skip to content

Commit

Permalink
Improved: Refactored removeStoreFromFacility to add error handling fo…
Browse files Browse the repository at this point in the history
…r updateFacility(#304)
  • Loading branch information
R-Sourabh committed Nov 20, 2024
1 parent 1dfc7a9 commit 9191a81
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/ProductStorePopover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down

0 comments on commit 9191a81

Please sign in to comment.