1
0
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:
2016-10-03 19:49:15 -04:00
parent 449b4ee760
commit 4f2f15783a
9 changed files with 304 additions and 2 deletions

View File

@ -0,0 +1,27 @@
var assign = require('object-assign');
var AccountConstants = require('../constants/AccountConstants');
module.exports = function(state = {}, action) {
switch (action.type) {
case AccountConstants.ACCOUNTS_FETCHED:
var accounts = {};
for (var i = 0; i < action.accounts.length; i++) {
var account = action.accounts[i];
accounts[account.AccountId] = account;
}
return accounts;
case AccountConstants.ACCOUNT_CREATED:
case AccountConstants.ACCOUNT_UPDATED:
var account = action.account;
return assign({}, state, {
[account.AccountId]: account
});
case AccountConstants.ACCOUNT_REMOVED:
var newstate = assign({}, state);
delete newstate[action.accountId];
return newstate;
default:
return state;
}
};