export default()

in app/addons/activetasks/reducers.js [90:141]


export default (state = initialState, {type, options}) => {
  switch (type) {
    case ActionTypes.ACTIVE_TASKS_FETCH_AND_SET:
      return {
        ...state,
        tasks: options,
        filteredTasks: filterTasks(state.searchTerm, state.selectedRadio, state.sortByHeader, options, state.headerIsAscending)
      };

    case ActionTypes.ACTIVE_TASKS_SWITCH_TAB:
      const filteredTasks = filterTasks(state.searchTerm, options, state.sortByHeader, state.tasks, headerIsAscending);
      return {
        ...state,
        selectedRadio: options,
        filteredTasks
      };

    case ActionTypes.ACTIVE_TASKS_CHANGE_POLLING_INTERVAL:
      return {
        ...state,
        pollingIntervalSeconds: options
      };

    case ActionTypes.ACTIVE_TASKS_SET_SEARCH_TERM:
      return setSearchTerm(state, options);

    case ActionTypes.ACTIVE_TASKS_SET_HIDDEN_COLUMNS:
      return {
        ...state,
        hiddenColumns: options
      };

    case ActionTypes.ACTIVE_TASKS_SORT_BY_COLUMN_HEADER:
      const prevSortbyHeader = state.sortByHeader;
      const sortByHeader = options;
      const headerIsAscending = setHeaderIsAscending(prevSortbyHeader, sortByHeader, state.headerIsAscending);
      const headerFilteredTasks = filterTasks(state.searchTerm, state.selectedRadio, sortByHeader, state.tasks, headerIsAscending);
      return {
        ...state,
        sortByHeader,
        headerIsAscending,
        filteredTasks: headerFilteredTasks
      };

    case ActionTypes.ACTIVE_TASKS_SET_IS_LOADING:
      return {
        ...state,
        isLoading: options
      };
  }
  return state;
};