diff --git a/src/services/UserService.ts b/src/services/UserService.ts index 401128c5..a64ed131 100644 --- a/src/services/UserService.ts +++ b/src/services/UserService.ts @@ -309,6 +309,14 @@ const getFieldMappings = async (payload: any): Promise => { }); } +const fetchFacilityPreferredInvGroups = async (payload: any): Promise => { + return api({ + url: "/service/fetchFacilityPreferredInvGroups", + method: "POST", + data: payload + }); +} + export const UserService = { addFacilityToGroup, createFieldMapping, @@ -330,5 +338,6 @@ export const UserService = { getUserPermissions, updateFacility, updateFacilityToGroup, - updateFieldMapping + updateFieldMapping, + fetchFacilityPreferredInvGroups } \ No newline at end of file diff --git a/src/views/Settings.vue b/src/views/Settings.vue index e164d085..a03e2bd7 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -113,15 +113,15 @@ {{ translate("Sell online") }} - + - + {{ translate("Channels") }} - + {{ group.facilityGroupName }} @@ -271,7 +271,8 @@ export default defineComponent({ orderLimitType: 'unlimited', fulfillmentOrderLimit: "" as number | string, facilityInventoryGroups: [] as any, - isEComInvEnabled: false + isEComInvEnabled: false, + facilityPreferredInvGroups: [] as any }; }, computed: { @@ -377,6 +378,24 @@ export default defineComponent({ } catch (err) { logger.error('Failed to fetch eCom inventory config', err) } + + try { + if(!this.isEComInvEnabled) { + resp = await UserService.fetchFacilityPreferredInvGroups({ + facilityId: this.currentFacility.facilityId, + oms: this.instanceUrl, + collection: 'FACILITY_PREFERENCE' + }) + + if(!hasError(resp)) { + this.facilityPreferredInvGroups = resp.data.docs + } else { + throw resp.data + } + } + } catch(err) { + logger.error(err) + } }, logout () { this.store.dispatch('user/logout', { isUserUnauthorised: false }).then((redirectionUrl) => { @@ -470,7 +489,7 @@ export default defineComponent({ await this.getEcomInvStatus() }, async addFacilityInvGroups() { - const addResponses = await Promise.allSettled(this.facilityInventoryGroups + const addResponses = await Promise.allSettled(this.facilityPreferredInvGroups .map(async (payload: any) => await UserService.addFacilityToGroup({ "facilityId": this.currentFacility.facilityId, "facilityGroupId": payload.facilityGroupId