mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-09-12 05:19:47 +00:00
showing total tipped amount
This commit is contained in:
parent
83ea59b794
commit
c0e49c5643
3 changed files with 25 additions and 58 deletions
|
@ -13,68 +13,33 @@ import I18nMessage from 'component/i18nMessage';
|
||||||
import { formatNumberWithCommas } from 'util/number';
|
import { formatNumberWithCommas } from 'util/number';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
balance: number,
|
totalTippedAmount: 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,
|
accountDetails: any,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const WALLET_CONSOLIDATE_UTXOS = 400;
|
|
||||||
const LARGE_WALLET_BALANCE = 100;
|
|
||||||
|
|
||||||
const WalletBalance = (props: Props) => {
|
const WalletBalance = (props: Props) => {
|
||||||
const {
|
const {
|
||||||
balance,
|
|
||||||
claimsBalance,
|
|
||||||
supportsBalance,
|
|
||||||
tipsBalance,
|
|
||||||
doOpenModal,
|
|
||||||
hasSynced,
|
|
||||||
doUtxoConsolidate,
|
|
||||||
doFetchUtxoCounts,
|
|
||||||
consolidatingUtxos,
|
|
||||||
consolidateIsPending,
|
|
||||||
massClaimingTips,
|
|
||||||
massClaimIsPending,
|
|
||||||
utxoCounts,
|
|
||||||
accountDetails,
|
accountDetails,
|
||||||
|
totalTippedAmount,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
console.log('account details');
|
|
||||||
console.log(accountDetails);
|
|
||||||
|
|
||||||
const [detailsExpanded, setDetailsExpanded] = React.useState(false);
|
const [detailsExpanded, setDetailsExpanded] = React.useState(false);
|
||||||
|
|
||||||
const { other: otherCount = 0 } = utxoCounts || {};
|
|
||||||
|
|
||||||
const totalBalance = balance + tipsBalance + supportsBalance + claimsBalance;
|
console.log('total tipped amount')
|
||||||
const totalLocked = tipsBalance + claimsBalance + supportsBalance;
|
console.log(totalTippedAmount)
|
||||||
const operationPending = massClaimIsPending || massClaimingTips || consolidateIsPending || consolidatingUtxos;
|
|
||||||
|
|
||||||
React.useEffect(() => {
|
// console.log('account details');
|
||||||
if (balance > LARGE_WALLET_BALANCE && detailsExpanded) {
|
// console.log(accountDetails);
|
||||||
doFetchUtxoCounts();
|
|
||||||
}
|
|
||||||
}, [doFetchUtxoCounts, balance, detailsExpanded]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>{1 == 1 && <Card
|
<>{1 == 1 && <Card
|
||||||
title={<><Icon size="18" icon={ICONS.FINANCE} />{accountDetails && accountDetails.total_received_unpaid/100} USD</>}
|
title={<><Icon size="18" icon={ICONS.FINANCE} />{totalTippedAmount} USD</>}
|
||||||
subtitle={
|
subtitle={
|
||||||
<I18nMessage>
|
<I18nMessage>
|
||||||
This is your remaining balance that can still be withdrawn to your bank account
|
The total amount you have tipped to different creators
|
||||||
</I18nMessage>
|
</I18nMessage>
|
||||||
}
|
}
|
||||||
actions={
|
actions={
|
||||||
|
|
|
@ -83,23 +83,15 @@ const WalletBalance = (props: Props) => {
|
||||||
|
|
||||||
const customerStatusResponse = await getCustomerStatus();
|
const customerStatusResponse = await getCustomerStatus();
|
||||||
|
|
||||||
let totalTippedAmount = 0;
|
|
||||||
|
|
||||||
for(const transaction of response){
|
|
||||||
totalTippedAmount = totalTippedAmount + transaction.tipped_amount
|
|
||||||
}
|
|
||||||
|
|
||||||
setTotalTippedAmount(totalTippedAmount / 100);
|
|
||||||
|
|
||||||
setLastFour(customerStatusResponse.PaymentMethods[0].card.last4);
|
setLastFour(customerStatusResponse.PaymentMethods[0].card.last4);
|
||||||
|
|
||||||
if (response.length > 10) response.length = 10;
|
if (response && response.length > 10) response.length = 10;
|
||||||
|
|
||||||
setPaymentHistoryTransactions(response);
|
setPaymentHistoryTransactions(response);
|
||||||
|
|
||||||
const subscriptions = [...response];
|
const subscriptions = [...response];
|
||||||
|
|
||||||
if(subscriptions.length > 2){
|
if(subscriptions && subscriptions.length > 2){
|
||||||
subscriptions.length = 2
|
subscriptions.length = 2
|
||||||
setSubscriptions([])
|
setSubscriptions([])
|
||||||
} else {
|
} else {
|
||||||
|
@ -109,7 +101,7 @@ const WalletBalance = (props: Props) => {
|
||||||
console.log(response);
|
console.log(response);
|
||||||
|
|
||||||
})();
|
})();
|
||||||
}, []);
|
}, [accountTransactions]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -117,7 +109,6 @@ const WalletBalance = (props: Props) => {
|
||||||
title={__('Payment History')}
|
title={__('Payment History')}
|
||||||
body={
|
body={
|
||||||
<>
|
<>
|
||||||
<h2>{totalTippedAmount}</h2>
|
|
||||||
<div className="table__wrapper">
|
<div className="table__wrapper">
|
||||||
<table className="table table--transactions">
|
<table className="table table--transactions">
|
||||||
<thead>
|
<thead>
|
||||||
|
|
|
@ -29,6 +29,8 @@ const WalletPage = (props: Props) => {
|
||||||
const [accountStatusResponse, setAccountStatusResponse] = React.useState();
|
const [accountStatusResponse, setAccountStatusResponse] = React.useState();
|
||||||
const [accountTransactionResponse, setAccountTransactionResponse] = React.useState();
|
const [accountTransactionResponse, setAccountTransactionResponse] = React.useState();
|
||||||
const [customerTransactions, setCustomerTransactions] = React.useState();
|
const [customerTransactions, setCustomerTransactions] = React.useState();
|
||||||
|
const [totalTippedAmount, setTotalTippedAmount] = React.useState(0);
|
||||||
|
|
||||||
|
|
||||||
function getPaymentHistory() {
|
function getPaymentHistory() {
|
||||||
return Lbryio.call(
|
return Lbryio.call(
|
||||||
|
@ -78,8 +80,17 @@ const WalletPage = (props: Props) => {
|
||||||
try {
|
try {
|
||||||
const response = await getAccountStatus();
|
const response = await getAccountStatus();
|
||||||
|
|
||||||
|
// get card payments customer has made
|
||||||
const customerTransactionResponse = await getPaymentHistory();
|
const customerTransactionResponse = await getPaymentHistory();
|
||||||
|
|
||||||
|
let totalTippedAmount = 0;
|
||||||
|
|
||||||
|
for(const transaction of customerTransactionResponse){
|
||||||
|
totalTippedAmount = totalTippedAmount + transaction.tipped_amount
|
||||||
|
}
|
||||||
|
|
||||||
|
setTotalTippedAmount(totalTippedAmount / 100);
|
||||||
|
|
||||||
console.log(customerTransactionResponse);
|
console.log(customerTransactionResponse);
|
||||||
|
|
||||||
setCustomerTransactions(customerTransactionResponse)
|
setCustomerTransactions(customerTransactionResponse)
|
||||||
|
@ -100,7 +111,7 @@ const WalletPage = (props: Props) => {
|
||||||
console.log(getAccountTransactions);
|
console.log(getAccountTransactions);
|
||||||
|
|
||||||
} catch (err){
|
} catch (err){
|
||||||
|
console.log(err);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
}, []);
|
}, []);
|
||||||
|
@ -210,7 +221,7 @@ const WalletPage = (props: Props) => {
|
||||||
<>
|
<>
|
||||||
{/* fiat payment history for tips made by user */}
|
{/* fiat payment history for tips made by user */}
|
||||||
<div className="payment-history-tab" style={{display: 'none'}}>
|
<div className="payment-history-tab" style={{display: 'none'}}>
|
||||||
<WalletFiatPaymentBalance accountDetails={accountStatusResponse} />
|
<WalletFiatPaymentBalance totalTippedAmount={totalTippedAmount} accountDetails={accountStatusResponse} />
|
||||||
<div style={{paddingTop: '25px'}}></div>
|
<div style={{paddingTop: '25px'}}></div>
|
||||||
<WalletFiatPaymentHistory transactions={customerTransactions}/>
|
<WalletFiatPaymentHistory transactions={customerTransactions}/>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue