get stuff ready for merge bugfix and cleanup requested changes fixing flow errors fix last flow error and touchups fiat and lbc tabs coming along support setting currency as the default tab via query param add wallet fiat balance fixing naming add fiat transactions using es6 to populate data should be fine but keeps crashing transaction listing working add no transactions thing about to add a third tab add third tab add card last 4 to transaction history some renaming show payments successfully show filler for subscriptions display if no transactions or subs working but in the wrong component approaching something thats working showing total tipped amount about to add last couple features cleanup More touchups adding last features calculate the total amount of unique creators tipped couple touchups remove transaction listings from settings add view transactions buttons small optimization add subscriptions section fix lot of linting errors and make command more userful
203 lines
6.6 KiB
JavaScript
203 lines
6.6 KiB
JavaScript
// @flow
|
|
import React from 'react';
|
|
import Button from 'component/button';
|
|
import Card from 'component/common/card';
|
|
import { Lbryio } from 'lbryinc';
|
|
import moment from 'moment';
|
|
|
|
type Props = {
|
|
accountDetails: any,
|
|
transactions: any,
|
|
totalTippedAmount: number,
|
|
};
|
|
|
|
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;
|
|
|
|
// reverse so most recent payments come first
|
|
if (accountTransactions) {
|
|
accountTransactions = accountTransactions.reverse();
|
|
}
|
|
|
|
// const [detailsExpanded, setDetailsExpanded] = React.useState(false);
|
|
// const [accountStatusResponse, setAccountStatusResponse] = React.useState();
|
|
// const [totalTippedAmount, setTotalTippedAmount] = React.useState(0);
|
|
|
|
const [paymentHistoryTransactions, setPaymentHistoryTransactions] = React.useState();
|
|
const [subscriptions, setSubscriptions] = React.useState();
|
|
|
|
const [lastFour, setLastFour] = React.useState();
|
|
|
|
var environment = 'test';
|
|
|
|
// function getPaymentHistory() {
|
|
// return Lbryio.call(
|
|
// 'customer',
|
|
// 'list',
|
|
// {
|
|
// environment,
|
|
// },
|
|
// 'post'
|
|
// ); };
|
|
|
|
function getCustomerStatus() {
|
|
return Lbryio.call(
|
|
'customer',
|
|
'status',
|
|
{
|
|
environment,
|
|
},
|
|
'post'
|
|
);
|
|
}
|
|
|
|
React.useEffect(() => {
|
|
(async function() {
|
|
let response = accountTransactions;
|
|
|
|
console.log('payment transactions');
|
|
console.log(response);
|
|
|
|
const customerStatusResponse = await getCustomerStatus();
|
|
|
|
setLastFour(customerStatusResponse.PaymentMethods[0].card.last4);
|
|
|
|
if (response && response.length > 10) response.length = 10;
|
|
|
|
setPaymentHistoryTransactions(response);
|
|
|
|
const subscriptions = [...response];
|
|
|
|
if (subscriptions && subscriptions.length > 2) {
|
|
subscriptions.length = 2;
|
|
setSubscriptions([]);
|
|
} else {
|
|
setSubscriptions([]);
|
|
}
|
|
|
|
console.log(response);
|
|
})();
|
|
}, [accountTransactions]);
|
|
|
|
return (
|
|
<>
|
|
<Card
|
|
title={__('Payment History')}
|
|
body={
|
|
<>
|
|
<div className="table__wrapper">
|
|
<table className="table table--transactions">
|
|
<thead>
|
|
<tr>
|
|
<th className="date-header">{__('Date')}</th>
|
|
<th>{<>{__('Receiving Channel Name')}</>}</th>
|
|
<th>{__('Tip Location')}</th>
|
|
<th>{__('Amount (USD)')} </th>
|
|
<th>{__('Card Last 4')}</th>
|
|
<th>{__('Anonymous')}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{accountTransactions &&
|
|
accountTransactions.map((transaction) => (
|
|
<tr key={transaction.name + transaction.created_at}>
|
|
<td>{moment(transaction.created_at).format('LLL')}</td>
|
|
<td>
|
|
<Button
|
|
className="stripe__card-link-text"
|
|
navigate={'/' + transaction.channel_name + ':' + transaction.channel_claim_id}
|
|
label={transaction.channel_name}
|
|
button="link"
|
|
/>
|
|
</td>
|
|
<td>
|
|
<Button
|
|
className="stripe__card-link-text"
|
|
navigate={'/' + transaction.channel_name + ':' + transaction.source_claim_id}
|
|
label={
|
|
transaction.channel_claim_id === transaction.source_claim_id
|
|
? 'Channel Page'
|
|
: 'File Page'
|
|
}
|
|
button="link"
|
|
/>
|
|
</td>
|
|
<td>${transaction.tipped_amount / 100}</td>
|
|
<td>{lastFour}</td>
|
|
<td>{transaction.private_tip ? 'Yes' : 'No'}</td>
|
|
</tr>
|
|
))}
|
|
</tbody>
|
|
</table>
|
|
{(!accountTransactions || accountTransactions.length === 0) && <p style={{textAlign: 'center', marginTop: '20px', fontSize: '13px', color: 'rgb(171, 171, 171)'}}>No Transactions</p>}
|
|
</div>
|
|
</>
|
|
}
|
|
/>
|
|
|
|
<Card
|
|
title={__('Subscriptions')}
|
|
body={
|
|
<>
|
|
<div className="table__wrapper">
|
|
<table className="table table--transactions">
|
|
<thead>
|
|
<tr>
|
|
<th className="date-header">{__('Date')}</th>
|
|
<th>{<>{__('Receiving Channel Name')}</>}</th>
|
|
<th>{__('Tip Location')}</th>
|
|
<th>{__('Amount (USD)')} </th>
|
|
<th>{__('Card Last 4')}</th>
|
|
<th>{__('Anonymous')}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{subscriptions &&
|
|
subscriptions.reverse().map((transaction) => (
|
|
<tr key={transaction.name + transaction.created_at}>
|
|
<td>{moment(transaction.created_at).format('LLL')}</td>
|
|
<td>
|
|
<Button
|
|
className="stripe__card-link-text"
|
|
navigate={'/' + transaction.channel_name + ':' + transaction.channel_claim_id}
|
|
label={transaction.channel_name}
|
|
button="link"
|
|
/>
|
|
</td>
|
|
<td>
|
|
<Button
|
|
className="stripe__card-link-text"
|
|
navigate={'/' + transaction.channel_name + ':' + transaction.source_claim_id}
|
|
label={
|
|
transaction.channel_claim_id === transaction.source_claim_id
|
|
? 'Channel Page'
|
|
: 'File Page'
|
|
}
|
|
button="link"
|
|
/>
|
|
</td>
|
|
<td>${transaction.tipped_amount / 100}</td>
|
|
<td>{lastFour}</td>
|
|
<td>{transaction.private_tip ? 'Yes' : 'No'}</td>
|
|
</tr>
|
|
))}
|
|
</tbody>
|
|
</table>
|
|
{(!subscriptions || subscriptions.length === 0) && <p style={{textAlign: 'center', marginTop: '22px', fontSize: '13px', color: 'rgb(171, 171, 171)'}}>No Subscriptions</p>}
|
|
</div>
|
|
</>
|
|
}
|
|
/>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default WalletBalance;
|