{"size": 1064, "ext": "js", "max_stars_repo_path": "src/reducers/RouteReducer.js", "max_stars_repo_name": "iansayre/bus-map-challenge", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/reducers/RouteReducer.js", "max_issues_repo_name": "iansayre/bus-map-challenge", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/reducers/RouteReducer.js", "max_forks_repo_name": "iansayre/bus-map-challenge", "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": 25.3333333333, "max_line_length": 60, "alphanum_fraction": 0.6578947368}
/* Routes Reducer */

import RouteActions from '../actions/RouteActions';

const initialState = {
  isFetchingRoutes: false,
  routes: {},
  vehicleRoute: {},
  vehicleLocation: {},
  vehicleLocationArray: []
}

function RouteReducer(state = initialState, action = null) {
  switch(action.type) {
    case RouteActions.POPULATE_LOCATION_ARRAY:
      return Object.assign({}, state, {
        vehicleLocationArray: action.payload
      });
    case RouteActions.REQUEST_ROUTES:
      return Object.assign({}, state, {
        isFetchingRoutes: true
      });
    case RouteActions.RECEIVE_ROUTES:
      return Object.assign({}, state, {
        isFetchingRoutes: action.payload.isFetching,
        routes: action.payload.routes
      });
    case RouteActions.RECEIVE_VEHICLE_LOCATION:
      return Object.assign({}, state, {
        vehicleLocation: action.payload
      });
    case RouteActions.SET_ROUTE:
      return Object.assign({}, state, {
        vehicleRoute: action.payload
      });
    default:
      return state;
  }
}

export default RouteReducer;
