-
Notifications
You must be signed in to change notification settings - Fork 295
/
AmountInputSkin.tsx
60 lines (55 loc) · 1.67 KB
/
AmountInputSkin.tsx
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
// @flow
import React, { Component } from 'react';
import { defineMessages, intlShape } from 'react-intl';
import BigNumber from 'bignumber.js';
import { InputSkin } from 'react-polymorph/lib/skins/simple/InputSkin';
import styles from './AmountInputSkin.scss';
export const messages = defineMessages({
feesLabel: {
id: 'wallet.amountInput.feesLabel',
defaultMessage: '!!!+ {amount} of fees',
description:
'Label for the "+ 12.042481 of fees" message above amount input field.',
},
calculatingFeesLabel: {
id: 'wallet.amountInput.calculatingFeesLabel',
defaultMessage: '!!!Calculating fees',
description:
'Label for the "Calculating fees" message above amount input field.',
},
});
type Props = {
currency: string,
fees: ?BigNumber,
total: ?BigNumber,
error: boolean,
isCalculatingFees: boolean,
};
export default class AmountInputSkin extends Component<Props> {
static contextTypes = {
intl: intlShape.isRequired,
};
render() {
const { error, fees, total, currency, isCalculatingFees } = this.props;
const { intl } = this.context;
return (
<div className={styles.root}>
<InputSkin {...this.props} />
{isCalculatingFees && (
<span className={styles.calculatingFees}>
{intl.formatMessage(messages.calculatingFeesLabel)}
</span>
)}
{fees && !error && !isCalculatingFees && (
<span className={styles.fees}>
{intl.formatMessage(messages.feesLabel, { amount: fees })}
</span>
)}
<span className={styles.total}>
{total && !error && `= ${total} `}
{currency}
</span>
</div>
);
}
}