From 497f37ae4cd43641ac6721d6c96803f2d2d5fce0 Mon Sep 17 00:00:00 2001 From: Anthony Date: Thu, 29 Jul 2021 19:29:05 +0200 Subject: [PATCH] approaching something thats working --- .../walletFiatAccountHistory/view.jsx | 30 +-------- .../walletFiatPaymentHistory/view.jsx | 62 ++++++++----------- ui/page/wallet/view.jsx | 40 +++++++++--- 3 files changed, 60 insertions(+), 72 deletions(-) diff --git a/ui/component/walletFiatAccountHistory/view.jsx b/ui/component/walletFiatAccountHistory/view.jsx index bd7447b69..bc8b2219a 100644 --- a/ui/component/walletFiatAccountHistory/view.jsx +++ b/ui/component/walletFiatAccountHistory/view.jsx @@ -34,24 +34,9 @@ type Props = { transactions: any, }; -export const WALLET_CONSOLIDATE_UTXOS = 400; -const LARGE_WALLET_BALANCE = 100; - const WalletBalance = (props: Props) => { const { - balance, - claimsBalance, - supportsBalance, - tipsBalance, - doOpenModal, - hasSynced, - doUtxoConsolidate, - doFetchUtxoCounts, - consolidatingUtxos, - consolidateIsPending, - massClaimingTips, - massClaimIsPending, - utxoCounts, + } = props; // receive transactions from parent component @@ -65,19 +50,6 @@ const WalletBalance = (props: Props) => { const [detailsExpanded, setDetailsExpanded] = React.useState(false); const [accountStatusResponse, setAccountStatusResponse] = React.useState(); - - const { other: otherCount = 0 } = utxoCounts || {}; - - const totalBalance = balance + tipsBalance + supportsBalance + claimsBalance; - const totalLocked = tipsBalance + claimsBalance + supportsBalance; - const operationPending = massClaimIsPending || massClaimingTips || consolidateIsPending || consolidatingUtxos; - - React.useEffect(() => { - if (balance > LARGE_WALLET_BALANCE && detailsExpanded) { - doFetchUtxoCounts(); - } - }, [doFetchUtxoCounts, balance, detailsExpanded]); - var environment = 'test'; function getAccountStatus(){ diff --git a/ui/component/walletFiatPaymentHistory/view.jsx b/ui/component/walletFiatPaymentHistory/view.jsx index 33d30a500..0e13e366c 100644 --- a/ui/component/walletFiatPaymentHistory/view.jsx +++ b/ui/component/walletFiatPaymentHistory/view.jsx @@ -15,21 +15,6 @@ import { Lbryio } from 'lbryinc'; import moment from 'moment'; type Props = { - balance: number, - totalBalance: number, - claimsBalance: number, - supportsBalance: number, - tipsBalance: number, - doOpenModal: (string) => void, - hasSynced: boolean, - doFetchUtxoCounts: () => void, - doUtxoConsolidate: () => void, - fetchingUtxoCounts: boolean, - consolidatingUtxos: boolean, - consolidateIsPending: boolean, - massClaimingTips: boolean, - massClaimIsPending: boolean, - utxoCounts: { [string]: number }, accountDetails: any, transactions: any, totalTippedAmount: number, @@ -43,6 +28,9 @@ const WalletBalance = (props: Props) => { // receive transactions from parent component let accountTransactions = props.transactions; + console.log('heres transactions') + console.log(accountTransactions); + // let totalTippedAmount = props.totalTippedAmount; // totalTippedAmount = 0; @@ -88,34 +76,38 @@ const WalletBalance = (props: Props) => { React.useEffect(() => { (async function(){ - let response = await getPaymentHistory(); + let response = accountTransactions; - const customerStatusResponse = await getCustomerStatus(); + console.log('payment transactions'); + console.log(response); - let totalTippedAmount = 0; + const customerStatusResponse = await getCustomerStatus(); - for(const transaction of response){ - totalTippedAmount = totalTippedAmount + transaction.tipped_amount - } + let totalTippedAmount = 0; - setTotalTippedAmount(totalTippedAmount / 100); + for(const transaction of response){ + totalTippedAmount = totalTippedAmount + transaction.tipped_amount + } - setLastFour(customerStatusResponse.PaymentMethods[0].card.last4); + setTotalTippedAmount(totalTippedAmount / 100); - if (response.length > 10) response.length = 10; + setLastFour(customerStatusResponse.PaymentMethods[0].card.last4); - setPaymentHistoryTransactions(response); + if (response.length > 10) response.length = 10; - const subscriptions = [...response]; + setPaymentHistoryTransactions(response); - if(subscriptions.length > 2){ - subscriptions.length = 2 - setSubscriptions([]) - } else { - setSubscriptions([]) - } + const subscriptions = [...response]; + + if(subscriptions.length > 2){ + subscriptions.length = 2 + setSubscriptions([]) + } else { + setSubscriptions([]) + } + + console.log(response); - console.log(response); })(); }, []); @@ -139,8 +131,8 @@ const WalletBalance = (props: Props) => { - {paymentHistoryTransactions && - paymentHistoryTransactions.reverse().map((transaction) => ( + {accountTransactions && + accountTransactions.map((transaction) => ( {moment(transaction.created_at).format('LLL')} diff --git a/ui/page/wallet/view.jsx b/ui/page/wallet/view.jsx index 2342f2c18..52b6c277f 100644 --- a/ui/page/wallet/view.jsx +++ b/ui/page/wallet/view.jsx @@ -22,11 +22,34 @@ const WalletPage = (props: Props) => { console.log(props); var stripeEnvironment = 'test'; + var environment = 'test'; const tab = new URLSearchParams(props.location.search).get('tab'); const [accountStatusResponse, setAccountStatusResponse] = React.useState(); const [accountTransactionResponse, setAccountTransactionResponse] = React.useState(); + const [customerTransactions, setCustomerTransactions] = React.useState(); + + function getPaymentHistory() { + return Lbryio.call( + 'customer', + 'list', + { + environment: stripeEnvironment, + }, + 'post' + )}; + + function getCustomerStatus(){ + return Lbryio.call( + 'customer', + 'status', + { + environment: stripeEnvironment, + }, + 'post' + ) + } function getAccountStatus(){ return Lbryio.call( @@ -55,13 +78,19 @@ const WalletPage = (props: Props) => { try { const response = await getAccountStatus(); + const customerTransactionResponse = await getPaymentHistory(); + + console.log(customerTransactionResponse); + + setCustomerTransactions(customerTransactionResponse) + console.log('account status'); console.log(response); setAccountStatusResponse(response); - // TODO: some weird naming clash + // TODO: some weird naming clash hence getAccountTransactionsa const getAccountTransactions = await getAccountTransactionsa(); console.log('transactions'); @@ -72,13 +101,7 @@ const WalletPage = (props: Props) => { } catch (err){ - - - - } - - })(); }, []); @@ -185,10 +208,11 @@ const WalletPage = (props: Props) => { )} <> + {/* fiat payment history for tips made by user */}
- +