1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2024-12-27 07:52:28 -05:00
moneygo/js/reducers/SelectedSecurityReducer.js

24 lines
656 B
JavaScript

var SecurityConstants = require('../constants/SecurityConstants');
var UserConstants = require('../constants/UserConstants');
module.exports = function(state = -1, action) {
switch (action.type) {
case SecurityConstants.SECURITIES_FETCHED:
for (var i = 0; i < action.securities.length; i++) {
if (action.securities[i].SecurityId == state)
return state;
}
return -1;
case SecurityConstants.SECURITY_REMOVED:
if (action.securityId == state)
return -1;
return state;
case SecurityConstants.SECURITY_SELECTED:
return action.securityId;
case UserConstants.USER_LOGGEDOUT:
return -1;
default:
return state;
}
};