Feat/logged in user data
This commit is contained in:
parent
41df7429d2
commit
595372bef0
15 changed files with 351 additions and 141 deletions
|
|
@ -2,15 +2,24 @@ import { createApiReducer, chainReducers, INITIAL_API_STATUS } from 'src/service
|
|||
|
||||
import { AuthState } from './types';
|
||||
import { AuthActionTypes } from './actions';
|
||||
import { CurrentUser } from '../types';
|
||||
|
||||
const initialCurrentUserState: CurrentUser = {
|
||||
email: null,
|
||||
name: null,
|
||||
preferredUsername: null,
|
||||
id: null,
|
||||
};
|
||||
|
||||
const initialState: AuthState = {
|
||||
token: null,
|
||||
userInfo: initialCurrentUserState,
|
||||
_status: INITIAL_API_STATUS,
|
||||
};
|
||||
|
||||
const auth = createApiReducer(
|
||||
[AuthActionTypes.SIGN_IN_START, AuthActionTypes.SIGN_IN_SUCCESS, AuthActionTypes.SIGN_IN_FAILURE],
|
||||
(data) => ({ token: data.accessToken }),
|
||||
(data) => ({ token: data.accessToken, userInfo: data.userInfo }),
|
||||
(data) => data.error.message,
|
||||
);
|
||||
|
||||
|
|
|
|||
Reference in a new issue