Last active
December 5, 2018 14:48
-
-
Save mvbattan/d3c94bcaf78a24f3e4f023e355f4ae64 to your computer and use it in GitHub Desktop.
Disable complexity
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 { actions } from './actions'; | |
| const initialState = { | |
| matches: [], | |
| matchesLoading: false, | |
| matchesError: null, | |
| pitches: [], | |
| pitchesLoading: false, | |
| pitchesError: null | |
| }; | |
| /* eslint-disable complexity */ | |
| function reducer(state = initialState, action) { | |
| switch (action.type) { | |
| case actions.GET_MATCHES: { | |
| return { ...state, matchesLoading: true }; | |
| } | |
| case actions.GET_MATCHES_SUCCESS: { | |
| return { | |
| ...state, | |
| matchesLoading: false, | |
| matchesError: null, | |
| matches: action.payload | |
| }; | |
| } | |
| case actions.GET_MATCHES_FAILURE: { | |
| return { | |
| ...state, | |
| matchesLoading: false, | |
| matchesError: action.payload | |
| }; | |
| } | |
| case actions.GET_PITCHES: { | |
| return { ...state, pitchesLoading: true }; | |
| } | |
| case actions.GET_PITCHES_SUCCESS: { | |
| return { | |
| ...state, | |
| pitches: action.payload, | |
| pitchesLoading: false, | |
| pitchesError: null | |
| }; | |
| } | |
| case actions.GET_PITCHES_FAILURE: { | |
| return { | |
| ...state, | |
| pitchesLoading: false, | |
| pitchesError: action.payload | |
| }; | |
| } | |
| case default: | |
| return state; | |
| } | |
| } | |
| /* eslint-enable complexity */ | |
| export default reducer; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment