From 24390d16187d3580a666f2df009b0f224ab2d189 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Wed, 17 Jan 2024 10:43:49 +0530 Subject: [PATCH 1/3] Fixed: inventory channel groups not showing until page refresh (#169) --- src/store/modules/facility/actions.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/store/modules/facility/actions.ts b/src/store/modules/facility/actions.ts index d0a30b82..9fb62e8c 100644 --- a/src/store/modules/facility/actions.ts +++ b/src/store/modules/facility/actions.ts @@ -183,6 +183,7 @@ const actions: ActionTree = { const current = cachedFacilities.find((facility: any) => facility.facilityId === payload.facilityId) if(current?.facilityId && !payload.skipState) { commit(types.FACILITY_CURRENT_UPDATED, current); + await dispatch('fetchFacilityAdditionalInformation', payload); return; } From c047579d8f9f84acaa504152b198825e827b06f0 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Thu, 18 Jan 2024 12:27:44 +0530 Subject: [PATCH 2/3] 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; } From 64784a47994485227d758b52688a3411fbc9e38c Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Fri, 19 Jan 2024 14:49:26 +0530 Subject: [PATCH 3/3] Improved: added comment for inventory groups fetching logic for better readability (#169) --- src/store/modules/facility/actions.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/store/modules/facility/actions.ts b/src/store/modules/facility/actions.ts index 941875a5..e62249b4 100644 --- a/src/store/modules/facility/actions.ts +++ b/src/store/modules/facility/actions.ts @@ -185,6 +185,7 @@ const actions: ActionTree = { // 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']; + // Creating a key called 'isChecked' for inventory groups already associated with current facility. inventoryGroups.forEach((group: any) => { const isChecked = (current.facilityGroupInfo?.some((facilityGroup: any) => facilityGroup?.facilityGroupId === group.facilityGroupId)) group.isChecked = isChecked ? isChecked : false;