diff --git a/ui/component/txoList/view.jsx b/ui/component/txoList/view.jsx index 1b2f4f95a..ea053e9e4 100644 --- a/ui/component/txoList/view.jsx +++ b/ui/component/txoList/view.jsx @@ -14,6 +14,15 @@ import HelpLink from 'component/common/help-link'; import FileExporter from 'component/common/file-exporter'; import WalletFiatPaymentHistory from 'component/walletFiatPaymentHistory'; import WalletFiatAccountHistory from 'component/walletFiatAccountHistory'; +import { STRIPE_PUBLIC_KEY } from '../../../config'; +import { Lbryio } from 'lbryinc'; + +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 = { search: string, @@ -48,6 +57,62 @@ function TxoList(props: Props) { transactionsFile, } = props; + const [accountTransactionResponse, setAccountTransactionResponse] = React.useState([]); + const [customerTransactions, setCustomerTransactions] = React.useState([]); + + function getPaymentHistory() { + return Lbryio.call( + 'customer', + 'list', + { + environment: stripeEnvironment, + }, + 'post' + ); + } + + function getAccountTransactionsa() { + return Lbryio.call( + 'account', + 'list', + { + environment: stripeEnvironment, + }, + 'post' + ); + } + + // calculate account transactions section + React.useEffect(() => { + (async function() { + try { + const getAccountTransactions = await getAccountTransactionsa(); + + setAccountTransactionResponse(getAccountTransactions); + } catch (err) { + console.log(err); + } + })(); + }, []); + + // populate customer payment data + React.useEffect(() => { + (async function() { + try { + // get card payments customer has made + let customerTransactionResponse = await getPaymentHistory(); + // console.log('amount of transactions'); + // console.log(customerTransactionResponse.length); + + customerTransactionResponse.reverse(); + + setCustomerTransactions(customerTransactionResponse); + } catch (err) { + console.log(err); + } + })(); + }, []); + const urlParams = new URLSearchParams(search); const page = urlParams.get(TXO.PAGE) || String(1); const pageSize = urlParams.get(TXO.PAGE_SIZE) || String(TXO.PAGE_SIZE_DEFAULT); @@ -376,49 +441,6 @@ function TxoList(props: Props) {