Newer
Older
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
import React, { Component } from 'react';
import { AccountHeader, Form as FetherForm } from 'fether-ui';
import { accountsInfo$ } from '@parity/light.js';
import light from '@parity/light.js-react';
import { Link, Redirect, withRouter } from 'react-router-dom';
import Health from '../Health';
import TokensList from './TokensList';
import withAccount from '../utils/withAccount';
Axel Chalon
committed
@withRouter
this.props.history.push(`/whitelist/${this.props.accountAddress}`);
handlePasswordChange = ({ target: { value } }) => {
this.setState({ password: value });
};
handleSubmit = event => {
const { accountAddress, createAccountStore, history } = this.props;
const { password } = this.state;
createAccountStore
.backupAccount(accountAddress, password)
.then(res => {
if (res) {
createAccountStore.clear();
setTimeout(() => history.push(`/accounts`), 5000);
}
})
.catch(err => {
this.toggleMsg(err.text + ' Please check your password and try again.');
});
};
toggleBackupScreen = () => {
const { toggleBackupScreen } = this.state;
this.setState({ toggleBackupScreen: !toggleBackupScreen });
};
renderPasswordFormField = password => {
<p>Unlock your account:</p>
</div>
<button className='button -tiny' onClick={this.toggleBackupScreen}>
Close
</button>
<fieldset className='form_fields center-md'>
onChange={this.handlePasswordChange}
required
Confirm Backup
</button>
</form>
</fieldset>
</div>
);
};
const { accountsInfo, accountAddress } = this.props;
// If the accountsInfo object is empty (i.e. no accounts), then we redirect
// to the accounts page to create an account
if (accountsInfo && !Object.keys(accountsInfo).length) {
{toggleBackupScreen ? this.renderPasswordFormField(password) : null}
<button className='button -tiny' onClick={this.toggleBackupScreen}>
Backup Account
</button>