mirror of
https://github.com/aclindsa/moneygo.git
synced 2025-07-02 04:18:38 -04:00
Initial plumbing for moving to Redux
This commit is contained in:
20
js/reducers/SelectedAccountReducer.js
Normal file
20
js/reducers/SelectedAccountReducer.js
Normal file
@ -0,0 +1,20 @@
|
||||
var AccountConstants = require('../constants/AccountConstants');
|
||||
|
||||
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;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user