Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// 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 } from 'react-router-dom';
import { withProps } from 'recompose';
import RequireHealth from '../../RequireHealthOverlay';
import TokenBalance from '../../Tokens/TokensList/TokenBalance';
import withAccount from '../../utils/withAccount';
import withBalance, { withEthBalance } from '../../utils/withBalance';
import withTokens from '../../utils/withTokens';
@inject('parityStore', 'sendStore')
@withTokens
@withProps(({ match: { params: { tokenAddress } }, tokens }) => ({
token: tokens[tokenAddress]
}))
@withAccount
@withBalance // Balance of current token (can be ETH)
@withEthBalance // ETH balance
@observer
class SignedTxSummary extends Component {
state = {
maxSelected: false
};
handleSubmit = values => {
const {
account: { address },
history,
sendStore,
token
} = this.props;
return sendStore
.sendRaw()
.then(() => history.push(`/send/${token.address}/from/${address}/sent`))
.catch(error => ({
password: error.text
}));
};
render () {
const {
account: { address },
sendStore: { tx },
token
} = this.props;
return (
<div>
<Header
left={
<Link to={`/tokens/${address}`} className='icon -back'>
Close
</Link>
}
title={token && <h1>Send {token.name}</h1>}
/>
<RequireHealth require='sync'>
<div className='window_content'>
<div className='box -padded'>
<TokenBalance
decimals={6}
drawers={[
<Form
key='txForm'
initialValues={{
from: address,
to: tx.to,
amount: tx.amount,
...tx
}}
onSubmit={this.handleSubmit}
render={({
handleSubmit,
valid,
validating,
values,
form: { mutators }
}) => (
<form className='send-form' onSubmit={handleSubmit}>
<fieldset className='form_fields'>
<Field
className='form_field_amount'
disabled
label='Amount'
name='amount'
render={FetherForm.Field}
type='number'
/>
<Field
as='textarea'
className='-sm'
disabled
label='To'
name='to'
render={FetherForm.Field}
/>
{values.to === values.from && (
<span>
<h3>WARNING:</h3>
<p>
The sender and receiver addresses are the same.
</p>
</span>
)}
</fieldset>
<nav className='form-nav'>
<button className='button'>Send</button>
</nav>
</form>
)}
/>
]}
onClick={null} // To disable cursor:pointer on card // TODO Can this be done better?
token={token}
/>
</div>
</div>
</RequireHealth>
</div>
);
}
}
export default SignedTxSummary;