Skip to content

Commit

Permalink
Merge pull request #176 from amansinghbais/169-inventoryGroupsNotRend…
Browse files Browse the repository at this point in the history
…ering

Fixed: inventory channel groups not showing until page refresh (#169)
  • Loading branch information
ravilodhi authored Jan 19, 2024
2 parents 4db7a83 + 64784a4 commit 9135e01
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/store/modules/facility/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,20 @@ const actions: ActionTree<FacilityState, RootState> = {
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'];
// 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;
});
current.inventoryGroups = inventoryGroups;
commit(types.FACILITY_CURRENT_UPDATED, current);
return;
}
Expand Down

0 comments on commit 9135e01

Please sign in to comment.