2016-10-26 06:58:14 -04:00
|
|
|
var connect = require('react-redux').connect;
|
|
|
|
|
|
|
|
var SecurityActions = require('../actions/SecurityActions');
|
|
|
|
var SecurityTemplateActions = require('../actions/SecurityTemplateActions');
|
2017-06-21 21:53:01 -04:00
|
|
|
var ErrorActions = require('../actions/ErrorActions');
|
|
|
|
|
2016-10-26 06:58:14 -04:00
|
|
|
var SecuritiesTab = require('../components/SecuritiesTab');
|
|
|
|
|
|
|
|
function mapStateToProps(state) {
|
|
|
|
var selectedSecurityAccounts = [];
|
2017-02-05 20:48:40 -05:00
|
|
|
for (var accountId in state.accounts.map) {
|
|
|
|
if (state.accounts.map.hasOwnProperty(accountId)
|
|
|
|
&& state.accounts.map[accountId].SecurityId == state.selectedSecurity)
|
|
|
|
selectedSecurityAccounts.push(state.accounts.map[accountId]);
|
2016-10-26 06:58:14 -04:00
|
|
|
}
|
|
|
|
return {
|
2017-06-21 21:53:01 -04:00
|
|
|
user: state.user,
|
2017-06-21 21:27:05 -04:00
|
|
|
securities: state.securities.map,
|
|
|
|
security_list: state.securities.list,
|
2016-10-26 06:58:14 -04:00
|
|
|
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))},
|
2017-06-21 21:53:01 -04:00
|
|
|
onSearchTemplates: function(search, type, limit) {dispatch(SecurityTemplateActions.search(search, type, limit))},
|
|
|
|
onUserError: function(error) {dispatch(ErrorActions.userError(error))}
|
2016-10-26 06:58:14 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = connect(
|
|
|
|
mapStateToProps,
|
|
|
|
mapDispatchToProps
|
|
|
|
)(SecuritiesTab)
|