import BigNumber from 'bignumber.js'; import * as _ from 'lodash'; import Dialog from 'material-ui/Dialog'; import FlatButton from 'material-ui/FlatButton'; import * as React from 'react'; import {AddressInput} from 'ts/components/inputs/address_input'; import {TokenAmountInput} from 'ts/components/inputs/token_amount_input'; import {Token, TokenState} from 'ts/types'; interface SendDialogProps { onComplete: (recipient: string, value: BigNumber) => void; onCancelled: () => void; isOpen: boolean; token: Token; tokenState: TokenState; } interface SendDialogState { value?: BigNumber; recipient: string; shouldShowIncompleteErrs: boolean; isAmountValid: boolean; } export class SendDialog extends React.Component { constructor() { super(); this.state = { recipient: '', shouldShowIncompleteErrs: false, isAmountValid: false, }; } public render() { const transferDialogActions = [ , , ]; return ( {this.renderSendDialogBody()} ); } private renderSendDialogBody() { return (
); } private onRecipientChange(recipient?: string) { this.setState({ shouldShowIncompleteErrs: false, recipient, }); } private onValueChange(isValid: boolean, amount?: BigNumber) { this.setState({ isAmountValid: isValid, value: amount, }); } private onSendClick() { if (this.hasErrors()) { this.setState({ shouldShowIncompleteErrs: true, }); } else { const value = this.state.value; this.setState({ recipient: undefined, value: undefined, }); this.props.onComplete(this.state.recipient, value); } } private onCancel() { this.setState({ value: undefined, }); this.props.onCancelled(); } private hasErrors() { return _.isUndefined(this.state.recipient) || _.isUndefined(this.state.value) || !this.state.isAmountValid; } }