{"size": 1946, "ext": "js", "max_stars_repo_path": "web/src/reducers/exchange.js", "max_stars_repo_name": "jacob210/QuantBot", "max_stars_repo_stars_event_min_datetime": "2016-12-26T07:47:33.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T17:54:31.000Z", "max_issues_repo_path": "web/src/reducers/exchange.js", "max_issues_repo_name": "jacob210/QuantBot", "max_issues_repo_issues_event_min_datetime": "2016-09-26T01:49:30.000Z", "max_issues_repo_issues_event_max_datetime": "2019-06-25T13:01:48.000Z", "max_forks_repo_path": "web/src/reducers/exchange.js", "max_forks_repo_name": "jacob210/QuantBot", "max_forks_repo_forks_event_min_datetime": "2016-12-26T07:51:39.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-21T03:16:03.000Z"}
{"max_stars_count": 760, "max_issues_count": 41, "max_forks_count": 213, "avg_line_length": 24.325, "max_line_length": 50, "alphanum_fraction": 0.5796505653}
import * as actions from '../constants/actions';
import assign from 'lodash/assign';

const EXCHANGE_INIT = {
  loading: false,
  types: [],
  total: 0,
  list: [],
  message: '',
};

function exchange(state = EXCHANGE_INIT, action) {
  switch (action.type) {
    case actions.RESET_ERROR:
      return assign({}, state, {
        loading: false,
        message: '',
      });
    case actions.EXCHANGE_TYPES_REQUEST:
      return assign({}, state, {
        loading: true,
      });
    case actions.EXCHANGE_TYPES_SUCCESS:
      return assign({}, state, {
        loading: false,
        types: action.types,
      });
    case actions.EXCHANGE_TYPES_FAILURE:
      return assign({}, state, {
        loading: false,
        message: action.message,
      });
    case actions.EXCHANGE_LIST_REQUEST:
      return assign({}, state, {
        loading: true,
      });
    case actions.EXCHANGE_LIST_SUCCESS:
      return assign({}, state, {
        loading: false,
        total: action.total,
        list: action.list,
      });
    case actions.EXCHANGE_LIST_FAILURE:
      return assign({}, state, {
        loading: false,
        message: action.message,
      });
    case actions.EXCHANGE_PUT_REQUEST:
      return assign({}, state, {
        loading: true,
      });
    case actions.EXCHANGE_PUT_SUCCESS:
      return assign({}, state, {
        loading: false,
      });
    case actions.EXCHANGE_PUT_FAILURE:
      return assign({}, state, {
        loading: false,
        message: action.message,
      });
    case actions.EXCHANGE_DELETE_REQUEST:
      return assign({}, state, {
        loading: true,
      });
    case actions.EXCHANGE_DELETE_SUCCESS:
      return assign({}, state, {
        loading: false,
      });
    case actions.EXCHANGE_DELETE_FAILURE:
      return assign({}, state, {
        loading: false,
        message: action.message,
      });
    default:
      return state;
  }
}

export default exchange;
