cluedin-widget
Version:
This is the project for creating and managing widgets in CluedIn.
62 lines (57 loc) • 2.24 kB
JavaScript
const constants = require( '../constants' );
const initialState = {
providers: [],
isFetching: false,
crawlerStats: {},
isFetchingAll: false,
allProviders: []
};
module.exports = function update( state = initialState, action = {} ) {
switch( action.type ) {
case constants.provider.REQUEST_ALL_PROVIDERS:
return Object.assign( {}, {
providers: state.providers,
isFetching: false,
crawlerStats: state.crawlerStats,
isFetchingAll: true,
allProviders: state.allProviders
} );
case constants.provider.RECEIVE_ALL_PROVIDERS:
return Object.assign( {}, {
providers: state.providers,
isFetching: false,
crawlerStats: state.crawlerStats,
isFetchingAll: false,
allProviders: action.data.allProviders
} );
case constants.provider.REQUEST_ACTIVE_PROVIDERS:
return Object.assign( {}, {
providers: state.providers,
isFetching: true,
crawlerStats: state.crawlerStats,
isFetchingAll: state.isFetchingAll,
allProviders: state.allProviders
} );
case constants.provider.RECEIVE_ACTIVE_PROVIDERS:
return Object.assign( {}, {
providers: action.data.providers,
isFetching: false,
crawlerStats: state.crawlerStats,
isFetchingAll: state.isFetchingAll,
allProviders: state.allProviders
} );
case constants.provider.RECEIVE_CRAWLER_STATS:
let newCrawlerStats = Object.assign( {}, state.crawlerStats );
newCrawlerStats[ action.data.crawlerStats.integrationId ] = action.data.crawlerStats;
return Object.assign( {}, {
providers: state.providers,
isFetching: state.isFetching,
crawlerStats: newCrawlerStats,
isFetchingAll: state.isFetchingAll,
allProviders: state.allProviders
} );
break;
default:
return state;
}
};