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
@observer
class Tokens extends Component {
password: "",
toggleBackupScreen: false,
error: ""
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 && res.type === "ACCOUNT_ERROR") {
_this.toggleError(
res.text + " Please check your password and try again."
);
} else {
createAccountStore.clear();
history.push(`/accounts`);
};
toggleBackupScreen = () => {
const { toggleBackupScreen } = this.state;
this.setState({ toggleBackupScreen: !toggleBackupScreen });
};
toggleError = err => {
this.setState({
error: err
});
};
renderPasswordFormField = password => {
<div className="text -centered">
<button className="button" onClick={this.toggleBackupScreen}>
close
</button>
<p>Unlock your account:</p>
</div>
<fieldset className="form_fields -centered">
<form key="createAccount" onSubmit={this.handleSubmit}>
onChange={this.handlePasswordChange}
required
<p className="error"> {error ? error : null} </p>
<button className="button -right" disabled={!password}>
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)
) : (
<button className="button" onClick={this.toggleBackupScreen}>
backup account
<nav className="footer-nav">
<div className="footer-nav_status">
<div className="footer-nav_icons">
<button className="button -tiny" onClick={this.handleGoToWhitelist}>