1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-24 11:01:41 +01:00
metamask-extension/ui/components/app/modals/new-account-modal/new-account-modal.container.js
2021-04-28 14:53:59 -05:00

45 lines
1.1 KiB
JavaScript

import { connect } from 'react-redux';
import * as actions from '../../../../store/actions';
import NewAccountModal from './new-account-modal.component';
function mapStateToProps(state) {
return {
...(state.appState.modal.modalState.props || {}),
};
}
function mapDispatchToProps(dispatch) {
return {
hideModal: () => dispatch(actions.hideModal()),
createAccount: (newAccountName) => {
return dispatch(actions.addNewAccount()).then((newAccountAddress) => {
if (newAccountName) {
dispatch(actions.setAccountLabel(newAccountAddress, newAccountName));
}
return newAccountAddress;
});
},
};
}
function mergeProps(stateProps, dispatchProps) {
const { onCreateNewAccount } = stateProps;
const { createAccount } = dispatchProps;
return {
...stateProps,
...dispatchProps,
onSave: (newAccountName) => {
return createAccount(newAccountName).then((newAccountAddress) =>
onCreateNewAccount(newAccountAddress),
);
},
};
}
export default connect(
mapStateToProps,
mapDispatchToProps,
mergeProps,
)(NewAccountModal);