You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
953 B
35 lines
953 B
4 years ago
|
import { connect } from 'react-redux';
|
||
|
import * as actions from '../../store/actions';
|
||
|
import { getMostRecentOverviewPage } from '../../ducks/history/history';
|
||
|
import NewAccountCreateForm from './new-account.component';
|
||
5 years ago
|
|
||
5 years ago
|
const mapStateToProps = (state) => {
|
||
4 years ago
|
const {
|
||
|
metamask: { identities = {} },
|
||
4 years ago
|
} = state;
|
||
|
const numberOfExistingAccounts = Object.keys(identities).length;
|
||
|
const newAccountNumber = numberOfExistingAccounts + 1;
|
||
5 years ago
|
|
||
|
return {
|
||
|
newAccountNumber,
|
||
5 years ago
|
mostRecentOverviewPage: getMostRecentOverviewPage(state),
|
||
4 years ago
|
};
|
||
|
};
|
||
5 years ago
|
|
||
5 years ago
|
const mapDispatchToProps = (dispatch) => {
|
||
5 years ago
|
return {
|
||
5 years ago
|
createAccount: (newAccountName) => {
|
||
4 years ago
|
return dispatch(actions.addNewAccount()).then((newAccountAddress) => {
|
||
|
if (newAccountName) {
|
||
4 years ago
|
dispatch(actions.setAccountLabel(newAccountAddress, newAccountName));
|
||
4 years ago
|
}
|
||
4 years ago
|
});
|
||
5 years ago
|
},
|
||
4 years ago
|
};
|
||
|
};
|
||
5 years ago
|
|
||
4 years ago
|
export default connect(
|
||
|
mapStateToProps,
|
||
|
mapDispatchToProps,
|
||
4 years ago
|
)(NewAccountCreateForm);
|