Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved: changed logic of api call for adding mutilple productStores to a facility(#309) #314

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading