import BigNumber from 'bignumber.js'; import Dialog from 'material-ui/Dialog'; import FlatButton from 'material-ui/FlatButton'; import RadioButton from 'material-ui/RadioButton'; import RadioButtonGroup from 'material-ui/RadioButton/RadioButtonGroup'; import * as React from 'react'; import {EthAmountInput} from 'ts/components/inputs/eth_amount_input'; import {TokenAmountInput} from 'ts/components/inputs/token_amount_input'; import {Side, Token, TokenState} from 'ts/types'; interface EthWethConversionDialogProps { onComplete: (direction: Side, value: BigNumber) => void; onCancelled: () => void; isOpen: boolean; token: Token; tokenState: TokenState; etherBalance: BigNumber; } interface EthWethConversionDialogState { value?: BigNumber; direction: Side; shouldShowIncompleteErrs: boolean; hasErrors: boolean; } export class EthWethConversionDialog extends React.Component { constructor() { super(); this.state = { direction: Side.deposit, shouldShowIncompleteErrs: false, hasErrors: true, }; } public render() { const convertDialogActions = [ , , ]; return ( {this.renderConversionDialogBody()} ); } private renderConversionDialogBody() { return (
{this.state.direction === Side.receive ? : }
); } private onConversionDirectionChange(e: any, direction: Side) { this.setState({ value: undefined, shouldShowIncompleteErrs: false, direction, hasErrors: true, }); } private onValueChange(isValid: boolean, amount?: BigNumber) { this.setState({ value: amount, hasErrors: !isValid, }); } private onConvertClick() { if (this.state.hasErrors) { this.setState({ shouldShowIncompleteErrs: true, }); } else { const value = this.state.value; this.setState({ value: undefined, }); this.props.onComplete(this.state.direction, value); } } private onCancel() { this.setState({ value: undefined, }); this.props.onCancelled(); } }