{"size": 855, "ext": "js", "max_stars_repo_path": "web/js/modules/data/reducers.js", "max_stars_repo_name": "abhigya-sodani/worldview", "max_stars_repo_stars_event_min_datetime": "2020-05-26T12:53:06.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-26T12:53:06.000Z", "max_issues_repo_path": "web/js/modules/data/reducers.js", "max_issues_repo_name": "katarenamatos/worldview", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "web/js/modules/data/reducers.js", "max_forks_repo_name": "katarenamatos/worldview", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.1470588235, "max_line_length": 79, "alphanum_fraction": 0.6631578947}
import { assign as lodashAssign } from 'lodash';
import {
  SELECT_PRODUCT,
  DATA_GRANULE_SELECT,
  DATA_GRANULE_UNSELECT,
} from './constants';
import { CHANGE_TAB } from '../sidebar/constants';

export const defaultDataState = {
  selectedProduct: '',
  selectedGranules: {},
  prefer: 'science',
  active: false,
};
export default function dataDownloadReducer(state = defaultDataState, action) {
  switch (action.type) {
    case SELECT_PRODUCT:
      return lodashAssign({}, state, {
        selectedProduct: action.id,
      });
    case DATA_GRANULE_SELECT:
    case DATA_GRANULE_UNSELECT:
      return lodashAssign({}, state, {
        selectedGranules: action.selectedGranules,
      });
    case CHANGE_TAB:
      return lodashAssign({}, state, {
        active: action.activeTab === 'download',
      });
    default:
      return state;
  }
}
