// @flow import * as MODALS from 'constants/modal_types'; import React from 'react'; import Button from 'component/button'; import { Form, FormField } from 'component/common/form'; import { Formik } from 'formik'; import validateSendTx from 'util/form-validation'; import Card from 'component/common/card'; import I18nMessage from 'component/i18nMessage'; import LbcSymbol from 'component/common/lbc-symbol'; import WalletSpendableBalanceHelp from 'component/walletSpendableBalanceHelp'; import classnames from 'classnames'; import ChannelSelector from 'component/channelSelector'; import ClaimPreview from 'component/claimPreview'; type Props = { openModal: (id: string, { destination: string, amount: string, isAddress: boolean }) => void, draftTransaction: { address: string, amount: string }, setDraftTransaction: ({ address: string, amount: string }) => void, balance: number, isAddress: boolean, setIsAddress: (boolean) => void, contentUri: string, contentError: string, contentClaim?: StreamClaim, setEnteredContentUri: (string) => void, confirmed: boolean, setConfirmed: (boolean) => void, sendLabel: string, setSendLabel: (string) => void, snack: ?{ linkTarget: ?string, linkText: ?string, message: string, isError: boolean, }, }; class WalletSend extends React.PureComponent { constructor() { super(); (this: any).handleSubmit = this.handleSubmit.bind(this); (this: any).handleClear = this.handleClear.bind(this); } handleSubmit() { const { draftTransaction, openModal, isAddress, contentUri, setConfirmed } = this.props; const destination = isAddress ? draftTransaction.address : contentUri; const amount = draftTransaction.amount; const modalProps = { destination, amount, isAddress, setConfirmed }; openModal(MODALS.CONFIRM_TRANSACTION, modalProps); } handleClear() { const { setDraftTransaction, setConfirmed } = this.props; setDraftTransaction({ address: '', amount: '', }); setConfirmed(false); } render() { const { draftTransaction, setDraftTransaction, balance, isAddress, setIsAddress, contentUri, contentClaim, setEnteredContentUri, contentError, confirmed, sendLabel, setSendLabel, snack, } = this.props; if (confirmed) { this.handleClear(); setSendLabel('Sending...'); } if (snack) setSendLabel('Send'); return ( }}>Send Credits to your friends or favorite creators. } actions={ (
{!isAddress && }
{!isAddress && ( setEnteredContentUri(event.target.value)} onBlur={handleBlur} value={values.search} /> )} {!isAddress && ( )} setDraftTransaction({ address: draftTransaction.address, amount: event.target.value }) } onBlur={handleBlur} value={draftTransaction.amount} /> {isAddress && ( setDraftTransaction({ address: event.target.value, amount: draftTransaction.amount }) } onBlur={handleBlur} value={draftTransaction.address} /> )}
)} /> } /> ); } } export default WalletSend;