Newer
Older
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
//
// SPDX-License-Identifier: MIT
import React, { Component } from 'react';
import { inject, observer } from 'mobx-react';
import memoize from 'lodash/memoize';
import { Route } from 'react-router-dom';
import AccountConfirm from './AccountConfirm';
import AccountCopyPhrase from './AccountCopyPhrase';
import AccountName from './AccountName';
import AccountPassword from './AccountPassword';
import AccountWritePhrase from './AccountWritePhrase';
@inject('createAccountStore')
@observer
class CreateAccount extends Component {
/**
* Creating account and importing accounts have different processes: 4 steps
* for importing, and 5 steps for creating
*/
getSteps = memoize(isImport => {
return isImport
? [AccountWritePhrase, AccountName, AccountPassword, AccountConfirm]
: [
AccountName,
AccountCopyPhrase,
AccountWritePhrase,
AccountPassword,
AccountConfirm
];
});
handleCreateAccount = () => {
this.props.createAccountStore.setIsImporting(false);
handleGoBack = () => this.props.history.goBack();
handleImportAccount = () => {
this.props.createAccountStore.setIsImporting(true);
const {
createAccountStore: { isImport },
match: {
params: { step }
} // Current step
} = this.props;
// Get all the steps of our account process
const Steps = this.getSteps(isImport);
<Header
left={
<a className='icon -back' onClick={this.handleGoBack}>
Back
<h1>{isImport ? 'Import account' : 'Create a new account'}</h1>
<div
className={[
'progress-indicator_step',
step > index ? '-complete' : ''
].join(' ')}
key={`progress-indicator_step${index + 1}`}
/>
<Route
component={StepComponent}
key={`Step${index + 1}`}
path={`/accounts/new/${index + 1}`}
/>
<nav className='footer-nav'>
<div className='footer-nav_option'>
<button
className='button -footer'
onClick={this.handleCreateAccount}
>
<button
className='button -footer'
onClick={this.handleImportAccount}
>
Import account
</button>
</p>
</div>
);
}
}
export default CreateAccount;