2016-10-05 13:36:47 -04:00
|
|
|
var connect = require('react-redux').connect;
|
|
|
|
|
|
|
|
var AccountActions = require('../actions/AccountActions');
|
2017-05-24 19:47:18 -04:00
|
|
|
var TransactionActions = require('../actions/TransactionActions');
|
2017-05-22 20:36:36 -04:00
|
|
|
|
2016-10-05 13:45:09 -04:00
|
|
|
var AccountsTab = require('../components/AccountsTab');
|
2016-10-05 13:36:47 -04:00
|
|
|
|
|
|
|
function mapStateToProps(state) {
|
|
|
|
var security_list = [];
|
|
|
|
for (var securityId in state.securities) {
|
|
|
|
if (state.securities.hasOwnProperty(securityId))
|
|
|
|
security_list.push(state.securities[securityId]);
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
accounts: state.accounts.map,
|
|
|
|
accountChildren: state.accounts.children,
|
|
|
|
securities: state.securities,
|
|
|
|
security_list: security_list,
|
2017-05-22 20:36:36 -04:00
|
|
|
selectedAccount: state.selectedAccount,
|
2017-05-24 19:47:18 -04:00
|
|
|
transactions: state.transactions,
|
2017-05-22 20:36:36 -04:00
|
|
|
transactionPage: state.transactionPage
|
2016-10-05 13:36:47 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function mapDispatchToProps(dispatch) {
|
|
|
|
return {
|
|
|
|
onCreateAccount: function(account) {dispatch(AccountActions.create(account))},
|
|
|
|
onUpdateAccount: function(account) {dispatch(AccountActions.update(account))},
|
2017-05-24 19:47:18 -04:00
|
|
|
onDeleteAccount: function(account) {dispatch(AccountActions.remove(account))},
|
2017-05-22 20:36:36 -04:00
|
|
|
onSelectAccount: function(accountId) {dispatch(AccountActions.select(accountId))},
|
2017-05-24 19:47:18 -04:00
|
|
|
onCreateTransaction: function(transaction) {dispatch(TransactionActions.create(transaction))},
|
|
|
|
onUpdateTransaction: function(transaction) {dispatch(TransactionActions.update(transaction))},
|
|
|
|
onDeleteTransaction: function(transaction) {dispatch(TransactionActions.remove(transaction))},
|
|
|
|
onSelectTransaction: function(transactionId) {dispatch(TransactionActions.select(transactionId))},
|
|
|
|
onUnselectTransaction: function() {dispatch(TransactionActions.unselect())},
|
|
|
|
onFetchTransactionPage: function(account, pageSize, page) {dispatch(TransactionActions.fetchPage(account, pageSize, page))},
|
2016-10-05 13:36:47 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = connect(
|
|
|
|
mapStateToProps,
|
|
|
|
mapDispatchToProps
|
|
|
|
)(AccountsTab)
|