mirror of
https://github.com/aclindsa/moneygo.git
synced 2024-11-17 03:50:05 -05:00
24 lines
656 B
JavaScript
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;
|
|
}
|
|
};
|