From 05d57bfca90c4cbee811f7b0c7542e01cb8c3cac Mon Sep 17 00:00:00 2001 From: k2maan Date: Thu, 30 Nov 2023 15:27:34 +0530 Subject: [PATCH] Fixed: facility not removed from state if no record is fetched --- src/store/modules/facility/actions.ts | 4 +++- src/store/modules/facility/mutation-types.ts | 1 - src/store/modules/facility/mutations.ts | 3 --- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/store/modules/facility/actions.ts b/src/store/modules/facility/actions.ts index 5eb1dd97..cba17a13 100644 --- a/src/store/modules/facility/actions.ts +++ b/src/store/modules/facility/actions.ts @@ -264,6 +264,7 @@ const actions: ActionTree = { }, async fetchFacilityLocations({ commit }, payload) { + let facilityLocations = [] try { const params = { inputFields: { @@ -277,13 +278,14 @@ const actions: ActionTree = { const resp = await FacilityService.fetchFacilityLocations(params) if(!hasError(resp) && resp.data.count > 0) { - commit(types.FACILITY_LOCATIONS_UPDATED, resp.data.docs) + facilityLocations = resp.data.docs } else { throw resp.data } } catch(err) { logger.error('Failed to find the facility locations', err) } + commit(types.FACILITY_LOCATIONS_UPDATED, facilityLocations) }, async fetchFacilityCalendar({commit}, payload) { diff --git a/src/store/modules/facility/mutation-types.ts b/src/store/modules/facility/mutation-types.ts index 864d31bf..aa9d96cc 100644 --- a/src/store/modules/facility/mutation-types.ts +++ b/src/store/modules/facility/mutation-types.ts @@ -2,7 +2,6 @@ export const SN_FACILITY = 'facility' export const FACILITY_LIST_UPDATED = SN_FACILITY + '/LIST_UPDATED' export const FACILITY_QUERY_UPDATED = SN_FACILITY + '/QUERY_UPDATED' export const FACILITY_CURRENT_UPDATED = SN_FACILITY + '/CURRENT_UPDATED' -export const FACILITY_CURRENT_LOCATION_UPDATED = SN_FACILITY + '/CURRENT_LOCATION_UPDATED' export const FACILITY_LOCATIONS_UPDATED = SN_FACILITY + '/LOCATIONS_UPDATED' export const FACILITY_POSTAL_ADDRESS_UPDATED = SN_FACILITY + '/POSTAL_ADDRESS_UPDATED' export const FACILITY_MAPPINGS_UPDATED = SN_FACILITY + '/MAPPINGS_UPDATED' diff --git a/src/store/modules/facility/mutations.ts b/src/store/modules/facility/mutations.ts index 12a86eef..54549eb6 100644 --- a/src/store/modules/facility/mutations.ts +++ b/src/store/modules/facility/mutations.ts @@ -16,9 +16,6 @@ const mutations: MutationTree = { [types.FACILITY_CURRENT_UPDATED](state, payload) { state.current = payload }, - [types.FACILITY_CURRENT_LOCATION_UPDATED](state, payload) { - state.current.locations = payload - }, [types.FACILITY_POSTAL_ADDRESS_UPDATED](state, payload) { state.current.postalAddress = payload },