{"size": 1816, "ext": "js", "max_stars_repo_path": "src/redux-store/reducers/category.js", "max_stars_repo_name": "haosaudi/Hao_Dashboard", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/redux-store/reducers/category.js", "max_issues_repo_name": "haosaudi/Hao_Dashboard", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/redux-store/reducers/category.js", "max_forks_repo_name": "haosaudi/Hao_Dashboard", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.2820512821, "max_line_length": 56, "alphanum_fraction": 0.5831497797}
import { ActionType } from '../actions'

const initialState = {
  isLoading: false,
  categories: [],
  category: {},
}

export default (state = initialState, action) => {
  switch (action.type) {
    case ActionType.GET_ALL_CATEGORIES:
      return { ...state, isLoading: true }
    case ActionType.GET_ALL_CATEGORIES_SUCCESS:
      return {
        ...state,
        isLoading: false,
        categories: action.payload,
      }
    case ActionType.GET_ALL_CATEGORIES_FAIL:
      return {
        ...state,
        isLoading: false,
      }
    case ActionType.GET_CATEGORY:
      return { ...state, isLoading: true, category: {} }
    case ActionType.GET_CATEGORY_SUCCESS:
      return {
        ...state,
        isLoading: false,
        category: action.payload,
      }
    case ActionType.GET_CATEGORY_FAIL:
      return {
        ...state,
        isLoading: false,
      }
    case ActionType.CATEGORY_ADD:
      return { ...state, isLoading: true }
    case ActionType.CATEGORY_ADD_SUCCESS:
      return {
        ...state,
        isLoading: false,
      }
    case ActionType.CATEGORY_ADD_FAIL:
      return {
        ...state,
        isLoading: false,
      }
    case ActionType.CATEGORY_UPDATE:
      return { ...state, isLoading: true }
    case ActionType.CATEGORY_UPDATE_SUCCESS:
      return {
        ...state,
        isLoading: false,
      }
    case ActionType.CATEGORY_UPDATE_FAIL:
      return {
        ...state,
        isLoading: false,
      }
    case ActionType.CATEGORY_DELETE:
      return { ...state, isLoading: true }
    case ActionType.CATEGORY_DELETE_SUCCESS:
      return {
        ...state,
        isLoading: false,
      }
    case ActionType.CATEGORY_DELETE_FAIL:
      return {
        ...state,
        isLoading: false,
      }

    default:
      return state
  }
}
