Created
February 11, 2019 20:47
-
-
Save bietkul/ebcb8c7ab3153bb719b77ecd6b823857 to your computer and use it in GitHub Desktop.
Product reducer
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
| import AppConstants from '../utils/constants'; | |
| const initialProductState = { | |
| error: undefined, | |
| product: undefined, | |
| loading: false, | |
| }; | |
| function product(state = initialProductState, action) { | |
| switch (action.type) { | |
| case AppConstants.PRODUCT.GET: | |
| return { | |
| ...initialProductState, | |
| loading: true | |
| }; | |
| case AppConstants.PRODUCT.GET_SUCCESS: | |
| return { | |
| ...state, | |
| product: action.payload, | |
| loading: false | |
| }; | |
| case AppConstants.PRODUCT.GET_ERROR: | |
| return { | |
| ...state, | |
| error: action.error, | |
| loading: false | |
| }; | |
| default: | |
| return state; | |
| } | |
| } | |
| export default product; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment