{"size": 797, "ext": "js", "max_stars_repo_path": "modules/Solutions/reducers/solutionsReducer.js", "max_stars_repo_name": "lanjakorn/expo-with-realworld", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "modules/Solutions/reducers/solutionsReducer.js", "max_issues_repo_name": "lanjakorn/expo-with-realworld", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "modules/Solutions/reducers/solutionsReducer.js", "max_forks_repo_name": "lanjakorn/expo-with-realworld", "max_forks_repo_forks_event_min_datetime": "2020-02-23T21:26:46.000Z", "max_forks_repo_forks_event_max_datetime": "2020-02-23T21:26:46.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 22.1388888889, "max_line_length": 70, "alphanum_fraction": 0.6662484316}
import {
  SOLUTIONS_FAILURE,
  SOLUTIONS_REQUEST,
  SOLUTIONS_SUCCESS,
  SET_CURRENT_SOLUTION,
  SET_SOLUTIONS,
} from '../types'

export const INITIAL_STATE = {
  solutionsById: {},
  solutionIds: [],
  solution: '',
  isFetching: false,
  errorMessage: '',
}

export default ( state = INITIAL_STATE, action ) => {
  switch ( action.type ) {
  case SET_SOLUTIONS:
    return { ...state, ...action.solutions }
  case SOLUTIONS_REQUEST:
    return { ...state, isFetching: true }
  case SOLUTIONS_SUCCESS:
    return { ...state, ...action.solutions, isFetching: false }
  case SOLUTIONS_FAILURE:
    return { ...state, isFetching: false, errorMessage: action.error }
  case SET_CURRENT_SOLUTION:
    return {
      ...state,
      solution: action.solution,
    }
  default:
    return state
  }
}
