From c047579d8f9f84acaa504152b198825e827b06f0 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Thu, 18 Jan 2024 12:27:44 +0530 Subject: [PATCH] Improved: inventory channel groups fetching logic to fetch when facility data is retrieved from cache (#244) --- src/store/modules/facility/actions.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/store/modules/facility/actions.ts b/src/store/modules/facility/actions.ts index 9fb62e8c..941875a5 100644 --- a/src/store/modules/facility/actions.ts +++ b/src/store/modules/facility/actions.ts @@ -177,13 +177,20 @@ const actions: ActionTree = { commit(types.FACILITY_CURRENT_UPDATED, facility) }, - async fetchCurrentFacility({ commit, dispatch, state }, payload) { + async fetchCurrentFacility({ commit, dispatch, rootGetters, state }, payload) { // checking that if the list contains basic information for facility then not fetching the same information again const cachedFacilities = JSON.parse(JSON.stringify(state.facilities.list)) const current = cachedFacilities.find((facility: any) => facility.facilityId === payload.facilityId) if(current?.facilityId && !payload.skipState) { + // As inventory channels are fetched while fetching additional facility info + // But here we already have additional facility info, so just getting and adding inventory groups to current. + const inventoryGroups = rootGetters['util/getInventoryGroups']; + inventoryGroups.forEach((group: any) => { + const isChecked = (current.facilityGroupInfo?.some((facilityGroup: any) => facilityGroup?.facilityGroupId === group.facilityGroupId)) + group.isChecked = isChecked ? isChecked : false; + }); + current.inventoryGroups = inventoryGroups; commit(types.FACILITY_CURRENT_UPDATED, current); - await dispatch('fetchFacilityAdditionalInformation', payload); return; }