From 71ae01b30ecbd89ea3c2048acb42e6c16c1f3362 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Wed, 15 Nov 2023 15:59:59 +0530 Subject: [PATCH] Improved: code to clear the util and facility state on logout(#2) --- src/store/modules/facility/actions.ts | 11 ++++++++++- src/store/modules/user/actions.ts | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/store/modules/facility/actions.ts b/src/store/modules/facility/actions.ts index 5de62162..7fde8a2d 100644 --- a/src/store/modules/facility/actions.ts +++ b/src/store/modules/facility/actions.ts @@ -70,7 +70,7 @@ const actions: ActionTree = { throw resp.data } } catch(error) { - console.error(error) + logger.error(error) } emitter.emit("dismissLoader"); @@ -79,6 +79,15 @@ const actions: ActionTree = { updateQuery({ commit }, query) { commit(types.FACILITY_QUERY_UPDATED, query) + }, + + clearFacilites({ commit }) { + commit(types.FACILITY_QUERY_UPDATED, { + queryString: '', + productStoreId: '', + facilityTypeId: '' + }) + commit(types.FACILITY_LIST_UPDATED , { facilities: [], total: 0 }); } } diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index 1ff3a6b0..2e71054b 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -141,6 +141,9 @@ const actions: ActionTree = { resetConfig(); resetPermissions(); + this.dispatch('util/clearUtilState') + this.dispatch('facility/clearFacilityState') + // reset plugin state on logout authStore.$reset() userStore.$reset()