1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2024-11-14 02:40:05 -05:00
moneygo/js/reducers/SecurityTemplateReducer.js

41 lines
1.1 KiB
JavaScript
Raw Normal View History

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: []
};
2017-06-21 21:25:38 -04:00
module.exports = function(state = initialState, action) {
switch (action.type) {
case SecurityTemplateConstants.SEARCH_SECURITY_TEMPLATES:
2017-06-21 21:25:38 -04:00
return assign({}, state, {
search: action.searchString,
type: action.searchType,
templates: []
2017-06-21 21:25:38 -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, {
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
});
case UserConstants.USER_LOGGEDOUT:
2017-06-21 21:25:38 -04:00
return assign({}, initialState, {
currencies: state.currencies
});
default:
return state;
}
};