Created
April 17, 2018 05:04
-
-
Save Ayyagaries/92c04adcb7aa6dad0b0ed30aecab96f8 to your computer and use it in GitHub Desktop.
Reducer Code
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 { | |
REQUEST_REP_SEARCH, | |
SUCCESS_REP_SEARCH, | |
RESET_DATA, | |
SHOW_ALERT, | |
} from '../actions/searchReps'; | |
const intitalState = { | |
showLoading: false, | |
repsFound: [], | |
showAlert: false, | |
}; | |
export default (state = intitalState, action) => { | |
switch (action.type) { | |
case SHOW_ALERT: { | |
return { | |
...state, | |
showLoading: false, | |
showAlert: true, | |
}; | |
} | |
case RESET_DATA: { | |
return { | |
...state, | |
showLoading: false, | |
repsFound: [], | |
showAlert: false, | |
}; | |
} | |
case REQUEST_REP_SEARCH: { | |
return { | |
...state, | |
repsFound: [], | |
showLoading: true, | |
showAlert: false, | |
}; | |
} | |
case SUCCESS_REP_SEARCH: | |
return { | |
...state, | |
repsFound: action.repsFound, | |
showLoading: false, | |
showAlert: false, | |
}; | |
default: | |
return state; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment