aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/containers/inputs/eth_amount_input.ts
blob: 9ef903b5556d59fc74d0245e565ca15301a429d5 (plain) (blame)
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
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as React from 'react';
import { connect } from 'react-redux';
import { State } from 'ts/redux/reducer';
import { ValidatedBigNumberCallback } from 'ts/types';
import { constants } from 'ts/utils/constants';

import { EthAmountInput as EthAmountInputComponent } from 'ts/components/inputs/eth_amount_input';

interface EthAmountInputProps {
    label?: string;
    amount?: BigNumber;
    hintText?: string;
    onChange: ValidatedBigNumberCallback;
    onErrorMsgChange?: (errorMsg: React.ReactNode) => void;
    shouldShowIncompleteErrs: boolean;
    shouldCheckBalance: boolean;
    shouldShowErrs?: boolean;
    shouldShowUnderline?: boolean;
    style?: React.CSSProperties;
    labelStyle?: React.CSSProperties;
    inputHintStyle?: React.CSSProperties;
}

interface ConnectedState {
    balance: BigNumber;
}

const mapStateToProps = (state: State, _ownProps: EthAmountInputProps): ConnectedState => ({
    balance: Web3Wrapper.toUnitAmount(state.userEtherBalanceInWei, constants.DECIMAL_PLACES_ETH),
});

export const EthAmountInput: React.ComponentClass<EthAmountInputProps> = connect(mapStateToProps)(
    EthAmountInputComponent,
);