approaching something thats working

This commit is contained in:
Anthony 2021-07-29 19:29:05 +02:00
parent 0b07d9afc0
commit 497f37ae4c
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,
};
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(){

View file

@ -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) => {
</tr>
</thead>
<tbody>
{paymentHistoryTransactions &&
paymentHistoryTransactions.reverse().map((transaction) => (
{accountTransactions &&
accountTransactions.map((transaction) => (
<tr key={transaction.name + transaction.created_at}>
<td>{moment(transaction.created_at).format('LLL')}</td>
<td>

View file

@ -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 */}
<div className="payment-history-tab" style={{display: 'none'}}>
<WalletFiatPaymentBalance accountDetails={accountStatusResponse} />
<div style={{paddingTop: '25px'}}></div>
<WalletFiatPaymentHistory transactions={accountTransactionResponse}/>
<WalletFiatPaymentHistory transactions={customerTransactions}/>
</div>
</>