// @flow import React from 'react'; import Button from 'component/button'; import { Lbryio } from 'lbryinc'; import moment from 'moment'; import { getStripeEnvironment } from 'util/stripe'; let stripeEnvironment = getStripeEnvironment(); type Props = { accountDetails: any, transactions: any, }; const WalletFiatPaymentHistory = (props: Props) => { // receive transactions from parent component const { transactions: accountTransactions } = props; const [lastFour, setLastFour] = React.useState(); function getSymbol(transaction) { if (transaction.currency === 'eur') { return '€'; } else { return '$'; } } function getCurrencyIso(transaction) { if (transaction.currency === 'eur') { return 'EUR'; } else { return 'USD'; } } function getCustomerStatus() { return Lbryio.call( 'customer', 'status', { environment: stripeEnvironment, }, 'post' ); } // TODO: this is actually incorrect, last4 should be populated based on the transaction not the current customer details React.useEffect(() => { (async function () { const customerStatusResponse = await getCustomerStatus(); const lastFour = customerStatusResponse.PaymentMethods && customerStatusResponse.PaymentMethods.length && customerStatusResponse.PaymentMethods[0].card.last4; setLastFour(lastFour); })(); }, []); return ( <>
{__('Date')} | {<>{__('Receiving Channel Name')}>} | {__('Tip Location')} | {__('Amount')} | {__('Card Last 4')} | {__('Anonymous')} |
---|---|---|---|---|---|
{moment(transaction.created_at).format('LLL')} | {/* receiving channel name */}{/* link to content or channel */} | {/* how much tipped */} | {getSymbol(transaction)} {transaction.tipped_amount / 100} {getCurrencyIso(transaction)} | {/* TODO: this is incorrect need it per transactions not per user */} {/* last four of credit card */}{lastFour} | {/* whether tip is anonymous or not */}{transaction.private_tip ? 'Yes' : 'No'} |
{__('No Transactions')}
)}