From 429e3bbd0d59d6726a391cbec85b0a8ecc5f64de Mon Sep 17 00:00:00 2001 From: Palash gupta Date: Thu, 19 May 2022 13:43:54 +0530 Subject: [PATCH] fix: logout is fixed --- frontend/src/api/utils.ts | 8 ++++++++ frontend/src/store/reducers/app.ts | 8 ++++++++ frontend/src/types/actions/app.ts | 11 ++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/frontend/src/api/utils.ts b/frontend/src/api/utils.ts index 56867927a8..fdfa6c32a4 100644 --- a/frontend/src/api/utils.ts +++ b/frontend/src/api/utils.ts @@ -5,6 +5,7 @@ import history from 'lib/history'; import store from 'store'; import { LOGGED_IN, + UPDATE_ORG, UPDATE_USER, UPDATE_USER_ACCESS_REFRESH_ACCESS_TOKEN, UPDATE_USER_ORG_ROLE, @@ -51,5 +52,12 @@ export const Logout = (): void => { }, }); + store.dispatch({ + type: UPDATE_ORG, + payload: { + org: [], + }, + }); + history.push(ROUTES.LOGIN); }; diff --git a/frontend/src/store/reducers/app.ts b/frontend/src/store/reducers/app.ts index 5d697f6004..614179103f 100644 --- a/frontend/src/store/reducers/app.ts +++ b/frontend/src/store/reducers/app.ts @@ -12,6 +12,7 @@ import { UPDATE_CURRENT_VERSION, UPDATE_LATEST_VERSION, UPDATE_LATEST_VERSION_ERROR, + UPDATE_ORG, UPDATE_ORG_NAME, UPDATE_USER, UPDATE_USER_ACCESS_REFRESH_ACCESS_TOKEN, @@ -193,6 +194,13 @@ const appReducer = ( }; } + case UPDATE_ORG: { + return { + ...state, + org: action.payload.org, + }; + } + default: return state; } diff --git a/frontend/src/types/actions/app.ts b/frontend/src/types/actions/app.ts index 829d8ad46f..88e55fb772 100644 --- a/frontend/src/types/actions/app.ts +++ b/frontend/src/types/actions/app.ts @@ -20,6 +20,7 @@ export const UPDATE_USER_IS_FETCH = 'UPDATE_USER_IS_FETCH'; export const UPDATE_USER_ORG_ROLE = 'UPDATE_USER_ORG_ROLE'; export const UPDATE_USER = 'UPDATE_USER'; export const UPDATE_ORG_NAME = 'UPDATE_ORG_NAME'; +export const UPDATE_ORG = 'UPDATE_ORG'; export interface SwitchDarkMode { type: typeof SWITCH_DARK_MODE; @@ -102,6 +103,13 @@ export interface UpdateOrgName { }; } +export interface UpdateOrg { + type: typeof UPDATE_ORG; + payload: { + org: AppReducer['org']; + }; +} + export type AppAction = | SwitchDarkMode | LoggedInUser @@ -113,4 +121,5 @@ export type AppAction = | UpdateUserIsFetched | UpdateUserOrgRole | UpdateUser - | UpdateOrgName; + | UpdateOrgName + | UpdateOrg;