diff --git a/app/routes/app/components/components/Form/components/Pay/Pay.js b/app/routes/app/components/components/Form/components/Pay/Pay.js index 9a5f5c3a..3ca726bd 100644 --- a/app/routes/app/components/components/Form/components/Pay/Pay.js +++ b/app/routes/app/components/components/Form/components/Pay/Pay.js @@ -1,122 +1,130 @@ -import React from 'react' +import React, { Component } from 'react' import PropTypes from 'prop-types' import { FaBolt, FaChain } from 'react-icons/lib/fa' import CurrencyIcon from '../../../../../../../components/CurrencyIcon' import { btc } from '../../../../../../../utils' import styles from './Pay.scss' -const Pay = ({ - paymentType, - setPaymentType, - invoiceAmount, - onchainAmount, - setOnchainAmount, - payment_request, - setPaymentRequest, - fetchInvoice, - payInvoice, - currency, - crypto, - close -}) => { - const payClicked = () => { - if (payment_request.length !== 124) { return } - - payInvoice(payment_request) - close() +class Pay extends Component { + componentDidUpdate() { + if (this.props.paymentType !== 'lnd') { this.amountInput.focus() } } - const paymentRequestOnChange = payreq => { - setPaymentRequest(payreq) - if (payreq.length === 124) { - setPaymentType('ln') - fetchInvoice(payreq) - } else if (payreq.length === 42) { - setPaymentType('onchain') - } else { - setPaymentType('') + render() { + const { + paymentType, + setPaymentType, + invoiceAmount, + onchainAmount, + setOnchainAmount, + payment_request, + setPaymentRequest, + fetchInvoice, + payInvoice, + currency, + crypto, + close + } = this.props + const payClicked = () => { + if (payment_request.length !== 124) { return } + + payInvoice(payment_request) + close() } - } - - const calculateAmount = value => (currency === 'usd' ? btc.satoshisToUsd(value, currentTicker.price_usd) : btc.satoshisToBtc(value)) - return ( -