mirror of
https://github.com/aclindsa/moneygo.git
synced 2024-10-30 07:40:05 -04: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;
|
|
}
|
|
};
|