mirror of
https://github.com/datahub-project/datahub.git
synced 2025-07-25 18:38:55 +00:00
38 lines
918 B
JavaScript
38 lines
918 B
JavaScript
import { ActionTypes } from 'wherehows-web/actions/browse';
|
|
|
|
/**
|
|
* Initial state for browse feature
|
|
* @type {{entity: string}}
|
|
*/
|
|
const initialState = {
|
|
entity: 'datasets',
|
|
isFetching: false,
|
|
browseData: {}
|
|
};
|
|
|
|
/**
|
|
* Reduces browse actions into state object
|
|
* @param {Object} state = initialState
|
|
* @param {Object} action Flux Standard Action FSA object
|
|
* @return {Object} final state of the browse key in the store
|
|
*/
|
|
export default (state = initialState, action = {}) => {
|
|
switch (action.type) {
|
|
case ActionTypes.REQUEST_BROWSE_DATA:
|
|
case ActionTypes.SELECT_BROWSE_DATA:
|
|
return Object.assign({}, state, {
|
|
isFetching: true,
|
|
entity: action.payload.entity
|
|
});
|
|
|
|
case ActionTypes.RECEIVE_BROWSE_DATA:
|
|
return Object.assign({}, state, {
|
|
isFetching: false,
|
|
browseData: action.payload.browseData
|
|
});
|
|
|
|
default:
|
|
return state;
|
|
}
|
|
};
|