// Copyright 2015-2019 Parity Technologies (UK) Ltd. // This file is part of Parity. // // SPDX-License-Identifier: BSD-3-Clause import React, { Component } from 'react'; import { Header } from 'fether-ui'; import { inject, observer } from 'mobx-react'; import { Link, Route } from 'react-router-dom'; import AccountCopyPhrase from './AccountCopyPhrase'; import AccountImportOptions from './AccountImportOptions'; import AccountRewritePhrase from './AccountRewritePhrase'; import AccountName from './AccountName'; import AccountPassword from './AccountPassword'; import Health from '../../Health'; import i18n, { packageNS } from '../../i18n'; import withAccountsInfo from '../../utils/withAccountsInfo'; @inject('createAccountStore') @withAccountsInfo @observer class CreateAccount extends Component { constructor (props) { super(props); props.createAccountStore.clear(); } /** * Creating account and importing accounts have different processes: 4 steps * for importing, and 5 steps for creating */ getSteps = isImport => isImport ? [AccountImportOptions, AccountName, AccountPassword] : [AccountName, AccountCopyPhrase, AccountRewritePhrase, AccountPassword]; handleToggleCreateImport = () => { const { createAccountStore, history, match: { params: { step } } } = this.props; createAccountStore.clear(); createAccountStore.setIsImport(!createAccountStore.isImport); // If we were further in the account creation, go back to step 1 if (step > 1) { history.push('/accounts/new/1'); } }; render () { const { accountsInfo, createAccountStore: { isImport }, match: { params: { step } } } = this.props; // Get all the steps of our account process const Steps = this.getSteps(isImport); return (
0 && ( Back ) } title={

{isImport ? i18n.t(`${packageNS}:account.import.title`) : i18n.t(`${packageNS}:account.create.title`)}

} />
{Steps.map((StepComponent, index) => ( ))}
{isImport ? null : ( )} ); } } export default CreateAccount;