// @flow import React from 'react'; import Button from 'component/button'; import { Lbryio } from 'lbryinc'; import moment from 'moment'; import { STRIPE_PUBLIC_KEY } from 'config'; let stripeEnvironment = 'test'; // if the key contains pk_live it's a live key // update the environment for the calls to the backend to indicate which environment to hit if (STRIPE_PUBLIC_KEY.indexOf('pk_live') > -1) { stripeEnvironment = 'live'; } type Props = { accountDetails: any, transactions: any, }; const WalletBalance = (props: Props) => { // receive transactions from parent component const { transactions: accountTransactions } = props; const [lastFour, setLastFour] = React.useState(); 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 ( <>
{/* table header */} {/* list data for transactions */} {accountTransactions && accountTransactions.map((transaction) => ( {/* date */} {/* receiving channel name */} {/* link to content or channel */} {/* how much tipped */} {/* TODO: this is incorrect need it per transactions not per user */} {/* last four of credit card */} {/* whether tip is anonymous or not */} ))}
{__('Date')} {<>{__('Receiving Channel Name')}} {__('Tip Location')} {__('Amount (USD)')} {__('Card Last 4')} {__('Anonymous')}
{moment(transaction.created_at).format('LLL')} ${transaction.tipped_amount / 100}{lastFour}{transaction.private_tip ? 'Yes' : 'No'}
{/* show some markup if there's no transactions */} {(!accountTransactions || accountTransactions.length === 0) &&

No Transactions

}
); }; export default WalletBalance;