2016-10-05 13:36:47 -04:00
|
|
|
var connect = require('react-redux').connect;
|
|
|
|
|
2017-06-10 14:38:40 -04:00
|
|
|
var SecurityActions = require('../actions/SecurityActions');
|
2016-10-05 13:36:47 -04:00
|
|
|
var AccountActions = require('../actions/AccountActions');
|
2017-05-24 19:47:18 -04:00
|
|
|
var TransactionActions = require('../actions/TransactionActions');
|
2017-06-04 16:01:42 -04:00
|
|
|
var ImportActions = require('../actions/ImportActions');
|
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-06-04 16:01:42 -04:00
|
|
|
transactionPage: state.transactionPage,
|
|
|
|
imports: state.imports
|
2016-10-05 13:36:47 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function mapDispatchToProps(dispatch) {
|
|
|
|
return {
|
2017-06-04 16:01:42 -04:00
|
|
|
onFetchAllAccounts: function() {dispatch(AccountActions.fetchAll())},
|
2016-10-05 13:36:47 -04:00
|
|
|
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-06-10 14:38:40 -04:00
|
|
|
onFetchAllSecurities: function() {dispatch(SecurityActions.fetchAll())},
|
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))},
|
2017-06-04 16:01:42 -04:00
|
|
|
onOpenImportModal: function() {dispatch(ImportActions.openModal())},
|
|
|
|
onCloseImportModal: function() {dispatch(ImportActions.closeModal())},
|
|
|
|
onImportOFX: function(account, password, startDate, endDate) {dispatch(ImportActions.importOFX(account, password, startDate, endDate))},
|
|
|
|
onImportOFXFile: function(inputElement, account) {dispatch(ImportActions.importOFXFile(inputElement, account))},
|
|
|
|
onImportGnucash: function(inputElement) {dispatch(ImportActions.importGnucash(inputElement))},
|
2016-10-05 13:36:47 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = connect(
|
|
|
|
mapStateToProps,
|
|
|
|
mapDispatchToProps
|
|
|
|
)(AccountsTab)
|