// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
//
// SPDX-License-Identifier: MIT
import React, { Component } from 'react';
import { FormField } from 'light-ui';
import { inject, observer } from 'mobx-react';
import CreateAccountContainer from '../CreateAccountContainer';
@inject('createAccountStore')
@observer
class AccountWritePhrase extends Component {
state = {
value: ''
};
handleChange = ({ target: { value } }) => this.setState({ value });
handleNextStep = () => {
const {
history,
location: { pathname }
} = this.props;
const currentStep = pathname.slice(-1);
history.push(`/accounts/new/${+currentStep + 1}`);
};
handleSavePhrase = () => {
const {
createAccountStore: { setPhrase }
} = this.props;
const { value } = this.state;
setPhrase(value).then(this.handleNextStep);
};
render () {
const { value } = this.state;
return (
Please write your recovery phrase:
}
label='Recovery phrase'
/>
);
}
renderButton = () => {
const {
createAccountStore: { isImport, phrase }
} = this.props;
const { value } = this.state;
// If we are creating a new account, the button just checks the phrase has
// been correctly written by the user.
if (!isImport) {
return (
);
}
// If we are importing an existing account, the button sets the phrase
return (
);
};
}
export default AccountWritePhrase;