1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2024-12-29 00:22:28 -05:00
moneygo/js/reducers/SelectedAccountReducer.js

24 lines
640 B
JavaScript
Raw Normal View History

2016-10-03 19:49:15 -04:00
var AccountConstants = require('../constants/AccountConstants');
2016-10-05 13:36:47 -04:00
var UserConstants = require('../constants/UserConstants');
2016-10-03 19:49:15 -04:00
module.exports = function(state = -1, action) {
switch (action.type) {
case AccountConstants.ACCOUNTS_FETCHED:
for (var i = 0; i < action.accounts.length; i++) {
if (action.accounts[i].AccountId == state)
return state;
}
return -1;
case AccountConstants.ACCOUNT_REMOVED:
if (action.accountId == state)
return -1;
return state;
case AccountConstants.ACCOUNT_SELECTED:
return action.accountId;
2016-10-05 13:36:47 -04:00
case UserConstants.USER_LOGGEDOUT:
return -1;
2016-10-03 19:49:15 -04:00
default:
return state;
}
};