Initial commit
This commit is contained in:
commit
fa30c04815
117 changed files with 33513 additions and 0 deletions
23
src/services/auth/redux/reducers.ts
Normal file
23
src/services/auth/redux/reducers.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { createApiReducer, chainReducers, INITIAL_API_STATUS, INITIAL_API_STATE } from 'src/services/api';
|
||||
|
||||
import { AuthState } from './types';
|
||||
import { AuthActionTypes } from './actions';
|
||||
|
||||
const initialState: AuthState = {
|
||||
token: null,
|
||||
_status: INITIAL_API_STATUS,
|
||||
};
|
||||
|
||||
const auth = createApiReducer(
|
||||
[AuthActionTypes.SIGN_IN_START, AuthActionTypes.SIGN_IN_SUCCESS, AuthActionTypes.SIGN_IN_FAILURE],
|
||||
(data) => ({ token: data.access_token }),
|
||||
(data) => data.error.message,
|
||||
);
|
||||
|
||||
const signOut = createApiReducer(
|
||||
['', AuthActionTypes.SIGN_OUT, ''],
|
||||
() => INITIAL_API_STATE,
|
||||
() => INITIAL_API_STATE,
|
||||
);
|
||||
|
||||
export default chainReducers(initialState, auth, signOut);
|
||||
Reference in a new issue