From ad69504278ed7fdfd2215133f65cf3931bbebfb5 Mon Sep 17 00:00:00 2001 From: Yury Date: Fri, 24 May 2024 15:30:29 +0300 Subject: [PATCH] chore(Store): added USER_LOGOUT action --- src/store/actions.ts | 6 ++++++ src/store/rootReducer.ts | 14 +++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/store/actions.ts b/src/store/actions.ts index 7512f80..a101199 100644 --- a/src/store/actions.ts +++ b/src/store/actions.ts @@ -16,3 +16,9 @@ export interface RestoreState { type: typeof ActionTypes.RESTORE_STATE payload: State } + +export const userLogOutAction = () => { + return { + type: ActionTypes.USER_LOGOUT + } +} diff --git a/src/store/rootReducer.ts b/src/store/rootReducer.ts index e7f4c33..517291c 100644 --- a/src/store/rootReducer.ts +++ b/src/store/rootReducer.ts @@ -6,6 +6,7 @@ import metadataReducer from './metadata/reducer' import userRobotImageReducer from './userRobotImage/reducer' import { RelaysState } from './relays/types' import relaysReducer from './relays/reducer' +import * as ActionTypes from './actionTypes' export interface State { auth: AuthState @@ -14,9 +15,20 @@ export interface State { relays: RelaysState } -export default combineReducers({ +export const appReducer = combineReducers({ auth: authReducer, metadata: metadataReducer, userRobotImage: userRobotImageReducer, relays: relaysReducer }) + +// FIXME: define types +export default (state: any, action: any) => { + switch (action.type) { + case ActionTypes.USER_LOGOUT: + return appReducer(undefined, action) + + default: + return appReducer(state, action) + } +}