Newer
Older
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
import React, { Component } from 'react';
import { AccountCard, Card, Form as FetherForm } from 'fether-ui';
import i18n, { packageNS } from '../../../i18n';
class AccountRewritePhrase extends Component {
isLoading: false,
handleChange = ({ target: { value } }) => {
this.setState({ value });
};
location: { pathname },
const currentStep = pathname.slice(-1);
// If we're importing, derive address from recovery phrase when we submit
this.setState({ isLoading: true });
await setPhrase(value);
}
history.push(`/accounts/new/${+currentStep + 1}`);
};
const currentStep = pathname.slice(-1);
Axel Chalon
committed
const body = [
<form key='createAccount' onSubmit={this.handleSubmit}>
Axel Chalon
committed
{isImport ? (
Axel Chalon
committed
) : (
<p>
{i18n.t(
`${packageNS}:account.phrase_rewrite.label_msg_rewrite_phrase`
)}
Axel Chalon
committed
</p>
)}
</div>
label={i18n.t(
`${packageNS}:account.phrase_rewrite.label_rewrite_phrase`
)}
onChange={this.handleChange}
required
value={value}
/>
Axel Chalon
committed
{currentStep > 1 && (
{i18n.t(`${packageNS}:navigation.back`)}
Axel Chalon
committed
</button>
)}
{this.renderButton()}
</nav>
Axel Chalon
committed
];
Amaury Martiny
committed
return isImport ? (
<Card>{body}</Card>
) : (
<AccountCard
address={address}
name={
address && !name
? i18n.t(`${packageNS}:account.existing.no_name`)
: name
}
drawers={body}
i18n={i18n}
packageNS={packageNS}
/>
createAccountStore: { isImport, bip39Phrase }
// If we are creating a new account, the button just checks the phrase has
// been correctly written by the user.
<button className='button' disabled={value !== bip39Phrase}>
{i18n.t(`${packageNS}:navigation.next`)}
// If we are importing an existing account, the button goes to the next step
<button className='button' disabled={!value.length || isLoading}>
{i18n.t(`${packageNS}:navigation.next`)}
export default AccountRewritePhrase;