Created
July 13, 2017 09:35
-
-
Save DanielKag/c5e7773dbca6270b68277220eda3686b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Main public safes state | |
| export interface ISafesState extends ISafesBaseState, | |
| IErrorState, | |
| IMasterDetailsState, | |
| ITabState | |
| {} | |
| // Private base safe state | |
| interface ISafesBaseState extends IState { | |
| dataListSettings: IFlattenState; | |
| datalist: IFlattenState; | |
| selectedSearch: string; | |
| } | |
| // Initial state for base safes | |
| const initialSafesState: ISafesBaseState = { | |
| dataListSettings : null, | |
| dataList: null, | |
| selectedSearch: null | |
| }; | |
| // Action creators | |
| const getSettingsAction = asyncActionTypeCreator('GET_SAFES_SETTINGS'); | |
| const getSafesAction = asyncActionTypeCreator('GET_SAFES'); | |
| // private base safe reducer | |
| const baseSafesReducer: Reducer<ISafesBaseState> = (state: ISafesBaseState = initialSafesState, action: IAction): ISafesBaseState => { | |
| switch (action.type) { | |
| case 'SET_SAFES_SERACH': | |
| return Object.assign({}, state, {selectedSearch: action.payload}); | |
| case getSettingsAction.SUCCESS: | |
| return getSettingsSuccessResult(state, action); | |
| case getSafesAction.SUCCESS: | |
| return Object.assign({}, state, {dataList: action.payload}); | |
| default: | |
| return state; | |
| } | |
| } | |
| // Public safesReducer | |
| export const safesReducer = extendReducer(baseSafesReducer, | |
| masterDetails('SAFES'), | |
| errorable('SAFES'), | |
| resetable('SAFES'), | |
| tabable('SAFES'), | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment