// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
//
// SPDX-License-Identifier: BSD-3-Clause
import React, { Component } from 'react';
import { Field, Form } from 'react-final-form';
import { Form as FetherForm, Header } from 'fether-ui';
import { inject, observer } from 'mobx-react';
import { Link, Redirect } from 'react-router-dom';
import { withProps } from 'recompose';
import RequireHealth from '../../RequireHealthOverlay';
import TokenBalance from '../../Tokens/TokensList/TokenBalance';
import withAccount from '../../utils/withAccount.js';
import withTokens from '../../utils/withTokens';
@inject('sendStore')
@withAccount
@withTokens
@withProps(({ match: { params: { tokenAddress } }, tokens }) => ({
token: tokens[tokenAddress]
}))
@observer
class Unlock extends Component {
handleAccept = values => {
const {
account: { address },
history,
sendStore,
token
} = this.props;
return sendStore
.send(values.password)
.then(() => history.push(`/send/${token.address}/from/${address}/sent`))
.catch(error => ({
password: error.text
}));
};
render () {
const {
account: { address },
history,
sendStore: { tx },
token
} = this.props;
if (!tx || !token) {
return