mirror of
https://github.com/aclindsa/moneygo.git
synced 2024-11-14 10:50:04 -05:00
36 lines
1.3 KiB
JavaScript
36 lines
1.3 KiB
JavaScript
|
var connect = require('react-redux').connect;
|
||
|
|
||
|
var SecurityActions = require('../actions/SecurityActions');
|
||
|
var SecurityTemplateActions = require('../actions/SecurityTemplateActions');
|
||
|
var SecuritiesTab = require('../components/SecuritiesTab');
|
||
|
|
||
|
function mapStateToProps(state) {
|
||
|
var selectedSecurityAccounts = [];
|
||
|
for (var accountId in state.accounts) {
|
||
|
if (state.accounts.hasOwnProperty(accountId)
|
||
|
&& state.accounts[accountId].SecurityId == state.selectedSecurity)
|
||
|
selectedSecurityAccounts.push(state.accounts[accountId]);
|
||
|
}
|
||
|
return {
|
||
|
securities: state.securities,
|
||
|
selectedSecurityAccounts: selectedSecurityAccounts,
|
||
|
selectedSecurity: state.selectedSecurity,
|
||
|
securityTemplates: state.securityTemplates
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function mapDispatchToProps(dispatch) {
|
||
|
return {
|
||
|
onCreateSecurity: function(security) {dispatch(SecurityActions.create(security))},
|
||
|
onUpdateSecurity: function(security) {dispatch(SecurityActions.update(security))},
|
||
|
onDeleteSecurity: function(securityId) {dispatch(SecurityActions.remove(securityId))},
|
||
|
onSelectSecurity: function(securityId) {dispatch(SecurityActions.select(securityId))},
|
||
|
onSearchTemplates: function(search, type, limit) {dispatch(SecurityTemplateActions.search(search, type, limit))}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = connect(
|
||
|
mapStateToProps,
|
||
|
mapDispatchToProps
|
||
|
)(SecuritiesTab)
|