2016-10-26 06:58:14 -04:00
|
|
|
var assign = require('object-assign');
|
|
|
|
|
|
|
|
var SecurityTemplateConstants = require('../constants/SecurityTemplateConstants');
|
|
|
|
var UserConstants = require('../constants/UserConstants');
|
|
|
|
|
2017-06-21 21:25:38 -04:00
|
|
|
const initialState = {
|
|
|
|
search: "",
|
|
|
|
type: 0,
|
|
|
|
templates: [],
|
|
|
|
currencies: []
|
|
|
|
};
|
2016-10-26 06:58:14 -04:00
|
|
|
|
2017-06-21 21:25:38 -04:00
|
|
|
module.exports = function(state = initialState, action) {
|
2016-10-26 06:58:14 -04:00
|
|
|
switch (action.type) {
|
|
|
|
case SecurityTemplateConstants.SEARCH_SECURITY_TEMPLATES:
|
2017-06-21 21:25:38 -04:00
|
|
|
return assign({}, state, {
|
2016-10-26 06:58:14 -04:00
|
|
|
search: action.searchString,
|
|
|
|
type: action.searchType,
|
|
|
|
templates: []
|
2017-06-21 21:25:38 -04:00
|
|
|
});
|
2016-10-26 06:58:14 -04:00
|
|
|
case SecurityTemplateConstants.SECURITY_TEMPLATES_SEARCHED:
|
|
|
|
if ((action.searchString != state.search) || (action.searchType != state.type))
|
|
|
|
return state;
|
2017-06-21 21:25:38 -04:00
|
|
|
return assign({}, state, {
|
2016-10-26 06:58:14 -04:00
|
|
|
search: action.searchString,
|
|
|
|
type: action.searchType,
|
|
|
|
templates: action.securities
|
2017-06-21 21:25:38 -04:00
|
|
|
});
|
|
|
|
case SecurityTemplateConstants.CURRENCIES_FETCHED:
|
|
|
|
return assign({}, state, {
|
|
|
|
currencies: action.currencies
|
|
|
|
});
|
2016-10-26 06:58:14 -04:00
|
|
|
case UserConstants.USER_LOGGEDOUT:
|
2017-06-21 21:25:38 -04:00
|
|
|
return assign({}, initialState, {
|
|
|
|
currencies: state.currencies
|
|
|
|
});
|
2016-10-26 06:58:14 -04:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
};
|