Skip to content

Instantly share code, notes, and snippets.

@mvbattan
Last active December 5, 2018 14:48
Show Gist options
  • Select an option

  • Save mvbattan/d3c94bcaf78a24f3e4f023e355f4ae64 to your computer and use it in GitHub Desktop.

Select an option

Save mvbattan/d3c94bcaf78a24f3e4f023e355f4ae64 to your computer and use it in GitHub Desktop.
Disable complexity
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