/* @flow */ 'use strict'; import React, { Component } from 'react'; import Select from 'react-select'; import AdvancedForm from './AdvancedForm'; import PendingTransactions from './PendingTransactions'; import { FeeSelectValue, FeeSelectOption } from './FeeSelect'; import { Notification } from '../../../common/Notification'; import AbstractAccount from '../AbstractAccount'; import { findAccountTokens } from '../../../../reducers/TokensReducer'; import type { Props } from './index'; import type { AccountState } from '../AbstractAccount'; export default class Send extends AbstractAccount { render() { return super.render() || _render(this.props, this.state); } } const _render = (props: Props, state: AccountState): React$Element => { const { device, account, discovery, deviceStatusNotification } = state; const abstractAccount = props.abstractAccount; if (!device || !account || !discovery || !abstractAccount) return
; const tokens = findAccountTokens(props.tokens, account); const { network } = abstractAccount; const { address, amount, setMax, coinSymbol, selectedCurrency, feeLevels, selectedFeeLevel, gasPriceNeedsUpdate, total, errors, warnings, infos, advanced, sending, } = props.sendForm; const { onAddressChange, onAmountChange, onSetMax, onCurrencyChange, onFeeLevelChange, updateFeeLevels, onSend, } = props.sendFormActions; const selectedCoin = abstractAccount.coin; const fiatRate = props.fiat.find(f => f.network === network); const tokensSelectData = tokens.map(t => { return { value: t.symbol, label: t.symbol }; }); tokensSelectData.unshift({ value: selectedCoin.symbol, label: selectedCoin.symbol }); const setMaxClassName: string = setMax ? 'set-max enabled' : 'set-max'; let updateFeeLevelsButton = null; if (gasPriceNeedsUpdate) { updateFeeLevelsButton = ( Recommended fees updated. Click here to use them ) } let addressClassName: ?string; if (errors.address) { addressClassName = 'not-valid'; } else if (warnings.address) { addressClassName = 'warning'; } else if (address.length > 0) { addressClassName = 'valid'; } let buttonDisabled: boolean = Object.keys(errors).length > 0 || total === '0' || amount.length === 0 || address.length === 0 || sending; let buttonLabel: string = 'Send'; if (coinSymbol !== selectedCurrency && amount.length > 0 && !errors.amount) { buttonLabel += ` ${amount} ${ selectedCurrency.toUpperCase() }` } else if (coinSymbol === selectedCurrency && total !== '0') { buttonLabel += ` ${total} ${ selectedCoin.symbol }`; } if (!device.connected){ buttonLabel = 'Device is not connected'; buttonDisabled = true; } else if (!device.available) { buttonLabel = 'Device is unavailable'; buttonDisabled = true; } else if (!discovery.completed) { buttonLabel = 'Loading accounts'; buttonDisabled = true; } let notification = null; return (
{ deviceStatusNotification }

Send Ethereum or tokens

onAddressChange(event.target.value) } /> { errors.address ? ({ errors.address }) : null } { warnings.address ? ({ warnings.address }) : null } { infos.address ? ({ infos.address }) : null }
onAmountChange(event.target.value) } /> Set max
); }