2017-04-21 15:43:48 -07:00
|
|
|
import { initialState, receiveEntities } from 'wherehows-web/reducers/entities';
|
2017-04-18 02:49:06 -07:00
|
|
|
import { ActionTypes } from 'wherehows-web/actions/datasets';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reduces the store state for datasets
|
|
|
|
* @param {Object} state = initialState the slice of the state object representing datasets
|
|
|
|
* @param {Object} action Flux Standard Action representing the action to be preformed on the state
|
|
|
|
* @prop {String} action.type actionType
|
2017-04-21 15:43:48 -07:00
|
|
|
* @return {Object}
|
2017-04-18 02:49:06 -07:00
|
|
|
*/
|
2017-04-21 15:43:48 -07:00
|
|
|
export default (state = initialState, action = {}) => {
|
2017-04-18 02:49:06 -07:00
|
|
|
switch (action.type) {
|
|
|
|
case ActionTypes.RECEIVE_PAGED_DATASETS:
|
2017-04-21 15:43:48 -07:00
|
|
|
return receiveEntities('datasets')(state, action.payload);
|
2017-04-18 02:49:06 -07:00
|
|
|
|
|
|
|
case ActionTypes.SELECT_PAGED_DATASETS:
|
|
|
|
case ActionTypes.REQUEST_PAGED_DATASETS:
|
|
|
|
return Object.assign({}, state, {
|
2017-04-21 15:43:48 -07:00
|
|
|
currentPage: action.payload.page,
|
|
|
|
pageBaseURL: action.payload.pageBaseURL,
|
|
|
|
isFetching: true
|
2017-04-18 02:49:06 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
};
|