Skip to content

Commit

Permalink
Merge pull request #314 from R-Sourabh/#309-facility-deadlock
Browse files Browse the repository at this point in the history
Improved: changed logic of api call for adding mutilple productStores to a facility(#309)
  • Loading branch information
ravilodhi authored Sep 18, 2024
2 parents 923000b + 4821838 commit 8b4911b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/views/AddFacilityConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,14 @@ export default defineComponent({
}
},
async addProductStoresToFacility() {
const responses = await Promise.allSettled(this.selectedProductStores
.map(async (payload: any) => await FacilityService.createProductStoreFacility({
let responses = []
for (const payload of this.selectedProductStores) {
responses.push(await FacilityService.createProductStoreFacility({
productStoreId: payload.productStoreId,
facilityId: this.facilityId,
fromDate: DateTime.now().toMillis(),
}))
)
}

const hasFailedResponse = responses.some((response: any) => response.status === 'rejected')
if (hasFailedResponse) {
Expand Down
7 changes: 4 additions & 3 deletions src/views/FacilityDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -791,13 +791,14 @@ export default defineComponent({
}))
)
const createResponses = await Promise.allSettled(productStoresToCreate
.map(async (payload: any) => await FacilityService.createProductStoreFacility({
let createResponses = []
for (const payload of productStoresToCreate) {
createResponses.push(await FacilityService.createProductStoreFacility({
productStoreId: payload.productStoreId,
facilityId: this.facilityId,
fromDate: DateTime.now().toMillis(),
}))
)
}
const hasFailedResponse = [...updateResponses, ...createResponses].some((response: any) => response.status === 'rejected')
if(hasFailedResponse) {
Expand Down

0 comments on commit 8b4911b

Please sign in to comment.