Created
April 11, 2017 09:07
-
-
Save brakmic/6b8b8544197ee3ccf0a6eeb3e60f53f6 to your computer and use it in GitHub Desktop.
reducer for handling customer actions
This file contains 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
import { ICustomerState, initialCustomerState } from '../states/sub-states'; | |
import { CustomerAction, CustomerActionTypes } from '../actions'; | |
export function customerReducer( | |
state: ICustomerState = initialCustomerState, | |
action: CustomerAction | |
): ICustomerState { | |
switch (action.type) { | |
case CustomerActionTypes.INITIALIZED: | |
return (<any>Object).assign({}, state, { | |
customer: action.payload | |
}); | |
case CustomerActionTypes.SAVED: | |
return (<any>Object).assign({}, state, { | |
customer: action.payload | |
}); | |
case CustomerActionTypes.DELETED: | |
return (<any>Object).assign({}, state, { | |
customer: undefined | |
}); | |
default: | |
return state; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment