From 48218380e2e8ccbb3f01920250d13612df9abcbb Mon Sep 17 00:00:00 2001 From: R-Sourabh Date: Fri, 13 Sep 2024 14:55:17 +0530 Subject: [PATCH] Improved: changed logic of api call for adding mutilple productStores to a facility(#309) --- src/views/AddFacilityConfig.vue | 7 ++++--- src/views/FacilityDetails.vue | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/views/AddFacilityConfig.vue b/src/views/AddFacilityConfig.vue index ed9b559b..e9154586 100644 --- a/src/views/AddFacilityConfig.vue +++ b/src/views/AddFacilityConfig.vue @@ -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) { diff --git a/src/views/FacilityDetails.vue b/src/views/FacilityDetails.vue index 15616f3b..7557f483 100644 --- a/src/views/FacilityDetails.vue +++ b/src/views/FacilityDetails.vue @@ -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) {