approaching something thats working

This commit is contained in:
Anthony 2021-07-29 19:29:05 +02:00
parent 35c73b00f8
commit 83ea59b794
No known key found for this signature in database
GPG key ID: C386D3C93D50E356
3 changed files with 60 additions and 72 deletions

View file

@ -34,24 +34,9 @@ type Props = {
transactions: any, transactions: 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,
} = props; } = props;
// receive transactions from parent component // receive transactions from parent component
@ -65,19 +50,6 @@ const WalletBalance = (props: Props) => {
const [detailsExpanded, setDetailsExpanded] = React.useState(false); const [detailsExpanded, setDetailsExpanded] = React.useState(false);
const [accountStatusResponse, setAccountStatusResponse] = React.useState(); 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'; var environment = 'test';
function getAccountStatus(){ function getAccountStatus(){

View file

@ -15,21 +15,6 @@ import { Lbryio } from 'lbryinc';
import moment from 'moment'; import moment from 'moment';
type Props = { 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, accountDetails: any,
transactions: any, transactions: any,
totalTippedAmount: number, totalTippedAmount: number,
@ -43,6 +28,9 @@ const WalletBalance = (props: Props) => {
// receive transactions from parent component // receive transactions from parent component
let accountTransactions = props.transactions; let accountTransactions = props.transactions;
console.log('heres transactions')
console.log(accountTransactions);
// let totalTippedAmount = props.totalTippedAmount; // let totalTippedAmount = props.totalTippedAmount;
// totalTippedAmount = 0; // totalTippedAmount = 0;
@ -88,7 +76,10 @@ const WalletBalance = (props: Props) => {
React.useEffect(() => { React.useEffect(() => {
(async function(){ (async function(){
let response = await getPaymentHistory(); let response = accountTransactions;
console.log('payment transactions');
console.log(response);
const customerStatusResponse = await getCustomerStatus(); const customerStatusResponse = await getCustomerStatus();
@ -116,6 +107,7 @@ const WalletBalance = (props: Props) => {
} }
console.log(response); console.log(response);
})(); })();
}, []); }, []);
@ -139,8 +131,8 @@ const WalletBalance = (props: Props) => {
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{paymentHistoryTransactions && {accountTransactions &&
paymentHistoryTransactions.reverse().map((transaction) => ( accountTransactions.map((transaction) => (
<tr key={transaction.name + transaction.created_at}> <tr key={transaction.name + transaction.created_at}>
<td>{moment(transaction.created_at).format('LLL')}</td> <td>{moment(transaction.created_at).format('LLL')}</td>
<td> <td>

View file

@ -22,11 +22,34 @@ const WalletPage = (props: Props) => {
console.log(props); console.log(props);
var stripeEnvironment = 'test'; var stripeEnvironment = 'test';
var environment = 'test';
const tab = new URLSearchParams(props.location.search).get('tab'); const tab = new URLSearchParams(props.location.search).get('tab');
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();
function getPaymentHistory() {
return Lbryio.call(
'customer',
'list',
{
environment: stripeEnvironment,
},
'post'
)};
function getCustomerStatus(){
return Lbryio.call(
'customer',
'status',
{
environment: stripeEnvironment,
},
'post'
)
}
function getAccountStatus(){ function getAccountStatus(){
return Lbryio.call( return Lbryio.call(
@ -55,13 +78,19 @@ const WalletPage = (props: Props) => {
try { try {
const response = await getAccountStatus(); const response = await getAccountStatus();
const customerTransactionResponse = await getPaymentHistory();
console.log(customerTransactionResponse);
setCustomerTransactions(customerTransactionResponse)
console.log('account status'); console.log('account status');
console.log(response); console.log(response);
setAccountStatusResponse(response); setAccountStatusResponse(response);
// TODO: some weird naming clash // TODO: some weird naming clash hence getAccountTransactionsa
const getAccountTransactions = await getAccountTransactionsa(); const getAccountTransactions = await getAccountTransactionsa();
console.log('transactions'); console.log('transactions');
@ -72,13 +101,7 @@ const WalletPage = (props: Props) => {
} catch (err){ } catch (err){
} }
})(); })();
}, []); }, []);
@ -185,10 +208,11 @@ const WalletPage = (props: Props) => {
)} )}
<> <>
{/* 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 accountDetails={accountStatusResponse} />
<div style={{paddingTop: '25px'}}></div> <div style={{paddingTop: '25px'}}></div>
<WalletFiatPaymentHistory transactions={accountTransactionResponse}/> <WalletFiatPaymentHistory transactions={customerTransactions}/>
</div> </div>
</> </>