Compare commits

...

12 commits

Author SHA1 Message Date
Anthony
4cd9062cfc
make fiat balance programatic again 2021-08-19 21:50:44 +02:00
Anthony
29cec219d3
cleaning up code 2021-08-19 19:55:06 +02:00
Anthony
8c9af6aa1d
coming along well 2021-08-19 19:41:58 +02:00
Anthony
32e6762ba8
getting real transactions 2021-08-19 17:26:37 +02:00
Anthony
815799a389
almost ready for refactor 2021-08-19 17:11:51 +02:00
Anthony
32e8672be5
tabs coming along well need to stack the cards 2021-08-19 16:30:47 +02:00
Anthony
78acb8d570
adding in payment history 2021-08-19 15:34:13 +02:00
Anthony
ab07b45e05
adding in transactions to existing table 2021-08-19 13:57:46 +02:00
Anthony
0df1852f5d
tab working 2021-08-19 13:29:10 +02:00
Anthony
d80182f91d
switching the tab system 2021-08-18 21:06:04 +02:00
Anthony
f1715660f8
refactoring the wallet iteration 2021-08-18 20:06:12 +02:00
Anthony
b3d3a1a454
mostly done with doing the iteration 2021-08-17 22:51:39 +02:00
7 changed files with 383 additions and 292 deletions

View file

@ -49,6 +49,11 @@ class CreditAmount extends React.PureComponent<Props> {
isFiat, isFiat,
} = this.props; } = this.props;
const minimumRenderableAmount = 10 ** (-1 * precision); const minimumRenderableAmount = 10 ** (-1 * precision);
// return null, otherwise it will try and convert undefined to a string
if (amount === undefined) {
return null;
}
const fullPrice = formatFullPrice(amount, 2); const fullPrice = formatFullPrice(amount, 2);
const isFree = parseFloat(amount) === 0; const isFree = parseFloat(amount) === 0;

View file

@ -12,6 +12,17 @@ import { toCapitalCase } from 'util/string';
import classnames from 'classnames'; import classnames from 'classnames';
import HelpLink from 'component/common/help-link'; import HelpLink from 'component/common/help-link';
import FileExporter from 'component/common/file-exporter'; import FileExporter from 'component/common/file-exporter';
import WalletFiatPaymentHistory from 'component/walletFiatPaymentHistory';
import WalletFiatAccountHistory from 'component/walletFiatAccountHistory';
import { STRIPE_PUBLIC_KEY } from '../../../config';
import { Lbryio } from 'lbryinc';
let stripeEnvironment = 'test';
// if the key contains pk_live it's a live key
// update the environment for the calls to the backend to indicate which environment to hit
if (STRIPE_PUBLIC_KEY.indexOf('pk_live') > -1) {
stripeEnvironment = 'live';
}
type Props = { type Props = {
search: string, search: string,
@ -30,6 +41,7 @@ type Props = {
type Delta = { type Delta = {
dkey: string, dkey: string,
value: string, value: string,
tab: string
}; };
function TxoList(props: Props) { function TxoList(props: Props) {
@ -45,12 +57,72 @@ function TxoList(props: Props) {
transactionsFile, transactionsFile,
} = props; } = props;
const [accountTransactionResponse, setAccountTransactionResponse] = React.useState([]);
const [customerTransactions, setCustomerTransactions] = React.useState([]);
function getPaymentHistory() {
return Lbryio.call(
'customer',
'list',
{
environment: stripeEnvironment,
},
'post'
);
}
function getAccountTransactionsa() {
return Lbryio.call(
'account',
'list',
{
environment: stripeEnvironment,
},
'post'
);
}
// calculate account transactions section
React.useEffect(() => {
(async function() {
try {
const getAccountTransactions = await getAccountTransactionsa();
setAccountTransactionResponse(getAccountTransactions);
} catch (err) {
console.log(err);
}
})();
}, []);
// populate customer payment data
React.useEffect(() => {
(async function() {
try {
// get card payments customer has made
let customerTransactionResponse = await getPaymentHistory();
// console.log('amount of transactions');
// console.log(customerTransactionResponse.length);
if (customerTransactionResponse && customerTransactionResponse.length) {
customerTransactionResponse.reverse();
}
setCustomerTransactions(customerTransactionResponse);
} catch (err) {
console.log(err);
}
})();
}, []);
const urlParams = new URLSearchParams(search); const urlParams = new URLSearchParams(search);
const page = urlParams.get(TXO.PAGE) || String(1); const page = urlParams.get(TXO.PAGE) || String(1);
const pageSize = urlParams.get(TXO.PAGE_SIZE) || String(TXO.PAGE_SIZE_DEFAULT); const pageSize = urlParams.get(TXO.PAGE_SIZE) || String(TXO.PAGE_SIZE_DEFAULT);
const type = urlParams.get(TXO.TYPE) || TXO.ALL; const type = urlParams.get(TXO.TYPE) || TXO.ALL;
const subtype = urlParams.get(TXO.SUB_TYPE); const subtype = urlParams.get(TXO.SUB_TYPE);
const active = urlParams.get(TXO.ACTIVE) || TXO.ALL; const active = urlParams.get(TXO.ACTIVE) || TXO.ALL;
const currency = urlParams.get('currency') || 'credits';
const fiatType = urlParams.get('fiatType') || 'incoming';
const currentUrlParams = { const currentUrlParams = {
page, page,
@ -58,6 +130,8 @@ function TxoList(props: Props) {
active, active,
type, type,
subtype, subtype,
currency,
fiatType,
}; };
const hideStatus = const hideStatus =
@ -119,8 +193,32 @@ function TxoList(props: Props) {
history.push(url); history.push(url);
} }
// let currency = 'credits';
function updateUrl(delta: Delta) { function updateUrl(delta: Delta) {
const newUrlParams = new URLSearchParams(); const newUrlParams = new URLSearchParams();
const existingCurrency = newUrlParams.get('currency') || 'credits';
const existingFiatType = newUrlParams.get('fiatType') || 'incoming';
console.log(existingFiatType);
console.log(newUrlParams);
// set tab name to account for wallet page tab
newUrlParams.set('tab', delta.tab);
// only update currency if it's being changed
if (delta.currency) {
newUrlParams.set('currency', delta.currency);
}
if (delta.fiatType) {
newUrlParams.set('fiatType', delta.fiatType);
} else {
newUrlParams.set('fiatType', existingFiatType);
}
switch (delta.dkey) { switch (delta.dkey) {
case TXO.PAGE: case TXO.PAGE:
if (currentUrlParams.type) { if (currentUrlParams.type) {
@ -179,6 +277,10 @@ function TxoList(props: Props) {
const paramsString = JSON.stringify(params); const paramsString = JSON.stringify(params);
// tab used in the wallet section
// TODO: change the name of this eventually
const tab = 'fiat-payment-history';
useEffect(() => { useEffect(() => {
if (paramsString && updateTxoPageParams) { if (paramsString && updateTxoPageParams) {
const params = JSON.parse(paramsString); const params = JSON.parse(paramsString);
@ -188,28 +290,54 @@ function TxoList(props: Props) {
return ( return (
<Card <Card
title={<div className="table__header-text">{__(`Transactions`)}</div>} title={
titleActions={ <><div className="table__header-text" style={{width: '124px', display: 'inline-block'}}>{__(`Transactions`)}</div>
<div className="card__actions--inline"> <div style={{display: 'inline-block'}}>
{!isFetchingTransactions && transactionsFile === null && ( <fieldset-section>
<label>{<span className="error__text">{__('Failed to process fetched data.')}</span>}</label> <div className={'txo__radios'}>
)} <Button
<div className="txo__export"> button="alt"
<FileExporter onClick={(e) => handleChange({ currency: 'credits', tab })}
data={transactionsFile} className={classnames(`button-toggle`, {
label={__('Export')} 'button-toggle--active': currency === 'credits',
tooltip={__('Fetch transaction data for export')} })}
defaultFileName={'transactions-history.csv'} label={__('Credits')}
onFetch={() => fetchTransactions()} />
progressMsg={isFetchingTransactions ? __('Fetching data') : ''} <Button
button="alt"
onClick={(e) => handleChange({ currency: 'fiat', tab })}
className={classnames(`button-toggle`, {
'button-toggle--active': currency === 'fiat',
})}
label={__('USD')}
/> />
</div> </div>
<Button button="alt" icon={ICONS.REFRESH} label={__('Refresh')} onClick={() => fetchTxoPage()} /> </fieldset-section>
</div> </div>
</>
}
titleActions={<></>
// <div className="card__actions--inline">
// {!isFetchingTransactions && transactionsFile === null && (
// <label>{<span className="error__text">{__('Failed to process fetched data.')}</span>}</label>
// )}
// <div className="txo__export">
// <FileExporter
// data={transactionsFile}
// label={__('Export')}
// tooltip={__('Fetch transaction data for export')}
// defaultFileName={'transactions-history.csv'}
// onFetch={() => fetchTransactions()}
// progressMsg={isFetchingTransactions ? __('Fetching data') : ''}
// />
// </div>
// <Button button="alt" icon={ICONS.REFRESH} label={__('Refresh')} onClick={() => fetchTxoPage()} />
// </div>
} }
isBodyList isBodyList
body={ body={currency === 'credits'
<div> ? <div>
<div className="card__body-actions"> <div className="card__body-actions">
<div className="card__actions"> <div className="card__actions">
<div> <div>
@ -223,7 +351,7 @@ function TxoList(props: Props) {
</> </>
} }
value={type || 'all'} value={type || 'all'}
onChange={(e) => handleChange({ dkey: TXO.TYPE, value: e.target.value })} onChange={(e) => handleChange({ dkey: TXO.TYPE, value: e.target.value, tab })}
> >
{Object.values(TXO.DROPDOWN_TYPES).map((v) => { {Object.values(TXO.DROPDOWN_TYPES).map((v) => {
const stringV = String(v); const stringV = String(v);
@ -242,7 +370,7 @@ function TxoList(props: Props) {
name="subtype" name="subtype"
label={__('Payment Type')} label={__('Payment Type')}
value={subtype || 'all'} value={subtype || 'all'}
onChange={(e) => handleChange({ dkey: TXO.SUB_TYPE, value: e.target.value })} onChange={(e) => handleChange({ dkey: TXO.SUB_TYPE, value: e.target.value, tab })}
> >
{Object.values(TXO.DROPDOWN_SUBTYPES).map((v) => { {Object.values(TXO.DROPDOWN_SUBTYPES).map((v) => {
const stringV = String(v); const stringV = String(v);
@ -262,7 +390,7 @@ function TxoList(props: Props) {
<div className={'txo__radios'}> <div className={'txo__radios'}>
<Button <Button
button="alt" button="alt"
onClick={(e) => handleChange({ dkey: TXO.ACTIVE, value: 'active' })} onClick={(e) => handleChange({ dkey: TXO.ACTIVE, value: 'active', tab })}
className={classnames(`button-toggle`, { className={classnames(`button-toggle`, {
'button-toggle--active': active === TXO.ACTIVE, 'button-toggle--active': active === TXO.ACTIVE,
})} })}
@ -270,7 +398,7 @@ function TxoList(props: Props) {
/> />
<Button <Button
button="alt" button="alt"
onClick={(e) => handleChange({ dkey: TXO.ACTIVE, value: 'spent' })} onClick={(e) => handleChange({ dkey: TXO.ACTIVE, value: 'spent', tab })}
className={classnames(`button-toggle`, { className={classnames(`button-toggle`, {
'button-toggle--active': active === 'spent', 'button-toggle--active': active === 'spent',
})} })}
@ -278,7 +406,7 @@ function TxoList(props: Props) {
/> />
<Button <Button
button="alt" button="alt"
onClick={(e) => handleChange({ dkey: TXO.ACTIVE, value: 'all' })} onClick={(e) => handleChange({ dkey: TXO.ACTIVE, value: 'all', tab })}
className={classnames(`button-toggle`, { className={classnames(`button-toggle`, {
'button-toggle--active': active === 'all', 'button-toggle--active': active === 'all',
})} })}
@ -288,12 +416,69 @@ function TxoList(props: Props) {
</fieldset-section> </fieldset-section>
</div> </div>
)} )}
<div className="card__actions--inline" style={{marginLeft: '181px'}}>
{!isFetchingTransactions && transactionsFile === null && (
<label>{<span className="error__text">{__('Failed to process fetched data.')}</span>}</label>
)}
<div className="txo__export">
<FileExporter
data={transactionsFile}
label={__('Export')}
tooltip={__('Fetch transaction data for export')}
defaultFileName={'transactions-history.csv'}
onFetch={() => fetchTransactions()}
progressMsg={isFetchingTransactions ? __('Fetching data') : ''}
/>
</div>
<Button button="alt" icon={ICONS.REFRESH} label={__('Refresh')} onClick={() => fetchTxoPage()} />
</div> </div>
</div> </div>
</div>
{/* listing of the transactions */}
<TransactionListTable txos={txoPage} /> <TransactionListTable txos={txoPage} />
<Paginate totalPages={Math.ceil(txoItemCount / Number(pageSize))} /> <Paginate totalPages={Math.ceil(txoItemCount / Number(pageSize))} />
</div> </div>
: <div>
{/* fiat section (buttons and transactions) */}
<div className="section card-stack">
<div className="card__body-actions">
<div className="card__actions">
{!hideStatus && (
<div>
<fieldset-section>
<label>{__('Type')}</label>
<div className={'txo__radios'}>
<Button
button="alt"
onClick={(e) => handleChange({ tab, fiatType: 'incoming', currency: 'fiat' })}
className={classnames(`button-toggle`, {
'button-toggle--active': fiatType === 'incoming',
})}
label={__('Incoming')}
/>
<Button
button="alt"
onClick={(e) => handleChange({ tab, fiatType: 'outgoing', currency: 'fiat' })}
className={classnames(`button-toggle`, {
'button-toggle--active': fiatType === 'outgoing',
})}
label={__('Outgoing')}
/>
</div>
</fieldset-section>
</div>
)}
</div>
</div>
{/* listing of the transactions */}
{ fiatType === 'incoming' && <WalletFiatAccountHistory transactions={accountTransactionResponse} /> }
{ fiatType === 'outgoing' && <WalletFiatPaymentHistory transactions={customerTransactions} /> }
{/* TODO: have to finish pagination */}
{/* <Paginate totalPages={Math.ceil(txoItemCount / Number(pageSize))} /> */}
</div>
</div>
} }
/> />
); );
} }

View file

@ -10,6 +10,8 @@ import Card from 'component/common/card';
import LbcSymbol from 'component/common/lbc-symbol'; import LbcSymbol from 'component/common/lbc-symbol';
import I18nMessage from 'component/i18nMessage'; import I18nMessage from 'component/i18nMessage';
import { formatNumberWithCommas } from 'util/number'; import { formatNumberWithCommas } from 'util/number';
import Icon from 'component/common/icon';
import WalletFiatBalance from 'component/walletFiatBalance';
type Props = { type Props = {
balance: number, balance: number,
@ -63,6 +65,7 @@ const WalletBalance = (props: Props) => {
}, [doFetchUtxoCounts, balance, detailsExpanded]); }, [doFetchUtxoCounts, balance, detailsExpanded]);
return ( return (
<div className={'columns'}>
<Card <Card
title={<LbcSymbol postfix={formatNumberWithCommas(totalBalance)} isTitle />} title={<LbcSymbol postfix={formatNumberWithCommas(totalBalance)} isTitle />}
subtitle={ subtitle={
@ -181,6 +184,10 @@ const WalletBalance = (props: Props) => {
</> </>
} }
/> />
{/* fiat balance card */}
<WalletFiatBalance />
</div>
); );
}; };

View file

@ -21,15 +21,11 @@ const WalletBalance = (props: Props) => {
} }
// if there are more than 10 transactions, limit it to 10 for the frontend // if there are more than 10 transactions, limit it to 10 for the frontend
if (accountTransactions && accountTransactions.length > 10) { // if (accountTransactions && accountTransactions.length > 10) {
accountTransactions.length = 10; // accountTransactions.length = 10;
} // }
return ( return (
<><Card
title={'Tip History'}
body={(
<>
<div className="table__wrapper"> <div className="table__wrapper">
<table className="table table--transactions"> <table className="table table--transactions">
<thead> <thead>
@ -78,10 +74,7 @@ const WalletBalance = (props: Props) => {
</table> </table>
{!accountTransactions && <p style={{textAlign: 'center', marginTop: '20px', fontSize: '13px', color: 'rgb(171, 171, 171)'}}>No Transactions</p>} {!accountTransactions && <p style={{textAlign: 'center', marginTop: '20px', fontSize: '13px', color: 'rgb(171, 171, 171)'}}>No Transactions</p>}
</div> </div>
</>
)}
/>
</>
); );
}; };

View file

@ -6,83 +6,69 @@ import Button from 'component/button';
import Card from 'component/common/card'; import Card from 'component/common/card';
import Icon from 'component/common/icon'; import Icon from 'component/common/icon';
import I18nMessage from 'component/i18nMessage'; import I18nMessage from 'component/i18nMessage';
import { Lbryio } from 'lbryinc';
import { STRIPE_PUBLIC_KEY } from 'config';
type Props = { let stripeEnvironment = 'test';
accountDetails: any, // if the key contains pk_live it's a live key
}; // update the environment for the calls to the backend to indicate which environment to hit
if (STRIPE_PUBLIC_KEY.indexOf('pk_live') > -1) {
stripeEnvironment = 'live';
}
const WalletBalance = (props: Props) => { const WalletBalance = (props: Props) => {
const { const [accountStatusResponse, setAccountStatusResponse] = React.useState();
accountDetails,
} = props; function getAccountStatus() {
return Lbryio.call(
'account',
'status',
{
environment: stripeEnvironment,
},
'post'
);
}
// calculate account transactions section
React.useEffect(() => {
(async function () {
try {
if (!stripeEnvironment) {
return;
}
const response = await getAccountStatus();
setAccountStatusResponse(response);
} catch (err) {
console.log(err);
}
})();
}, [stripeEnvironment]);
return ( return (
<>{<Card <>{<Card
title={<><Icon size={18} icon={ICONS.FINANCE} />{(accountDetails && ((accountDetails.total_received_unpaid - accountDetails.total_paid_out) / 100)) || 0} USD</>} title={<><Icon size={18} icon={ICONS.FINANCE} />{(accountStatusResponse && ((accountStatusResponse.total_received_unpaid - accountStatusResponse.total_paid_out) / 100)) || 0} USD</>}
subtitle={accountDetails && accountDetails.total_received_unpaid > 0 && subtitle={accountStatusResponse && accountStatusResponse.total_received_unpaid > 0 ? (
<I18nMessage> <I18nMessage>
This is your pending balance that will be automatically sent to your bank account This is your pending balance that will be automatically sent to your bank account
</I18nMessage> </I18nMessage>) : (
<I18nMessage>
When you begin to receive tips your balance will be updated here
</I18nMessage>)
} }
actions={ actions={
<> <>
<h2 className="section__title--small"> <h2 className="section__title--small">
${(accountDetails && (accountDetails.total_received_unpaid / 100)) || 0} Total Received Tips ${(accountStatusResponse && (accountStatusResponse.total_received_unpaid / 100)) || 0} Total Received Tips
</h2> </h2>
<h2 className="section__title--small"> <h2 className="section__title--small">
${(accountDetails && (accountDetails.total_paid_out / 100)) || 0} Withdrawn ${(accountStatusResponse && (accountStatusResponse.total_paid_out / 100)) || 0} Withdrawn
{/* <Button */}
{/* button="link" */}
{/* label={detailsExpanded ? __('View less') : __('View more')} */}
{/* iconRight={detailsExpanded ? ICONS.UP : ICONS.DOWN} */}
{/* onClick={() => setDetailsExpanded(!detailsExpanded)} */}
{/* /> */}
</h2> </h2>
{/* view more section */}
{/* commenting out because not implemented, but could be used in the future */}
{/* {detailsExpanded && ( */}
{/* <div className="section__subtitle"> */}
{/* <dl> */}
{/* <dt> */}
{/* <span className="dt__text">{__('Earned from uploads')}</span> */}
{/* /!* <span className="help--dt">({__('Earned from channel page')})</span> *!/ */}
{/* </dt> */}
{/* <dd> */}
{/* <span className="dd__text"> */}
{/* {Boolean(1) && ( */}
{/* <Button */}
{/* button="link" */}
{/* className="dd__button" */}
{/* icon={ICONS.UNLOCK} */}
{/* /> */}
{/* )} */}
{/* <CreditAmount amount={1} precision={4} /> */}
{/* </span> */}
{/* </dd> */}
{/* <dt> */}
{/* <span className="dt__text">{__('Earned from channel page')}</span> */}
{/* /!* <span className="help--dt">({__('Delete or edit past content to spend')})</span> *!/ */}
{/* </dt> */}
{/* <dd> */}
{/* <CreditAmount amount={1} precision={4} /> */}
{/* </dd> */}
{/* /!* <dt> *!/ */}
{/* /!* <span className="dt__text">{__('...supporting content')}</span> *!/ */}
{/* /!* <span className="help--dt">({__('Delete supports to spend')})</span> *!/ */}
{/* /!* </dt> *!/ */}
{/* /!* <dd> *!/ */}
{/* /!* <CreditAmount amount={1} precision={4} /> *!/ */}
{/* /!* </dd> *!/ */}
{/* </dl> */}
{/* </div> */}
{/* )} */}
<div className="section__actions"> <div className="section__actions">
{/* <Button button="primary" label={__('Receive Payout')} icon={ICONS.SEND} /> */}
<Button button="secondary" label={__('Account Configuration')} icon={ICONS.SETTINGS} navigate={`/$/${PAGES.SETTINGS_STRIPE_ACCOUNT}`} /> <Button button="secondary" label={__('Account Configuration')} icon={ICONS.SETTINGS} navigate={`/$/${PAGES.SETTINGS_STRIPE_ACCOUNT}`} />
</div> </div>
</> </>

View file

@ -1,7 +1,6 @@
// @flow // @flow
import React from 'react'; import React from 'react';
import Button from 'component/button'; import Button from 'component/button';
import Card from 'component/common/card';
import { Lbryio } from 'lbryinc'; import { Lbryio } from 'lbryinc';
import moment from 'moment'; import moment from 'moment';
import { STRIPE_PUBLIC_KEY } from 'config'; import { STRIPE_PUBLIC_KEY } from 'config';
@ -22,10 +21,6 @@ const WalletBalance = (props: Props) => {
// receive transactions from parent component // receive transactions from parent component
const { transactions: accountTransactions } = props; const { transactions: accountTransactions } = props;
// const [accountStatusResponse, setAccountStatusResponse] = React.useState();
// const [subscriptions, setSubscriptions] = React.useState();
const [lastFour, setLastFour] = React.useState(); const [lastFour, setLastFour] = React.useState();
function getCustomerStatus() { function getCustomerStatus() {
@ -52,12 +47,10 @@ const WalletBalance = (props: Props) => {
return ( return (
<> <>
<Card <div className="section card-stack">
title={__('Payment History')}
body={
<>
<div className="table__wrapper"> <div className="table__wrapper">
<table className="table table--transactions"> <table className="table table--transactions">
{/* table header */}
<thead> <thead>
<tr> <tr>
<th className="date-header">{__('Date')}</th> <th className="date-header">{__('Date')}</th>
@ -68,11 +61,14 @@ const WalletBalance = (props: Props) => {
<th>{__('Anonymous')}</th> <th>{__('Anonymous')}</th>
</tr> </tr>
</thead> </thead>
{/* list data for transactions */}
<tbody> <tbody>
{accountTransactions && {accountTransactions &&
accountTransactions.map((transaction) => ( accountTransactions.map((transaction) => (
<tr key={transaction.name + transaction.created_at}> <tr key={transaction.name + transaction.created_at}>
{/* date */}
<td>{moment(transaction.created_at).format('LLL')}</td> <td>{moment(transaction.created_at).format('LLL')}</td>
{/* receiving channel name */}
<td> <td>
<Button <Button
className="" className=""
@ -81,6 +77,7 @@ const WalletBalance = (props: Props) => {
button="link" button="link"
/> />
</td> </td>
{/* link to content or channel */}
<td> <td>
<Button <Button
className="" className=""
@ -93,18 +90,21 @@ const WalletBalance = (props: Props) => {
button="link" button="link"
/> />
</td> </td>
{/* how much tipped */}
<td>${transaction.tipped_amount / 100}</td> <td>${transaction.tipped_amount / 100}</td>
{/* TODO: this is incorrect need it per transactions not per user */}
{/* last four of credit card */}
<td>{lastFour}</td> <td>{lastFour}</td>
{/* whether tip is anonymous or not */}
<td>{transaction.private_tip ? 'Yes' : 'No'}</td> <td>{transaction.private_tip ? 'Yes' : 'No'}</td>
</tr> </tr>
))} ))}
</tbody> </tbody>
</table> </table>
{/* show some markup if there's no transactions */}
{(!accountTransactions || accountTransactions.length === 0) && <p style={{textAlign: 'center', marginTop: '20px', fontSize: '13px', color: 'rgb(171, 171, 171)'}}>No Transactions</p>} {(!accountTransactions || accountTransactions.length === 0) && <p style={{textAlign: 'center', marginTop: '20px', fontSize: '13px', color: 'rgb(171, 171, 171)'}}>No Transactions</p>}
</div> </div>
</> </div>
}
/>
</> </>
); );
}; };

View file

@ -2,10 +2,6 @@
import React from 'react'; import React from 'react';
import { useHistory } from 'react-router'; import { useHistory } from 'react-router';
import WalletBalance from 'component/walletBalance'; import WalletBalance from 'component/walletBalance';
import WalletFiatBalance from 'component/walletFiatBalance';
import WalletFiatPaymentBalance from 'component/walletFiatPaymentBalance';
import WalletFiatAccountHistory from 'component/walletFiatAccountHistory';
import WalletFiatPaymentHistory from 'component/walletFiatPaymentHistory';
import TxoList from 'component/txoList'; import TxoList from 'component/txoList';
import Page from 'component/page'; import Page from 'component/page';
import * as PAGES from 'constants/pages'; import * as PAGES from 'constants/pages';
@ -78,77 +74,6 @@ const WalletPage = (props: Props) => {
push(url); push(url);
} }
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 getAccountStatus() {
return Lbryio.call(
'account',
'status',
{
environment: stripeEnvironment,
},
'post'
);
}
function getAccountTransactionsa() {
return Lbryio.call(
'account',
'list',
{
environment: stripeEnvironment,
},
'post'
);
}
// calculate account transactions section
React.useEffect(() => {
(async function() {
try {
const response = await getAccountStatus();
setAccountStatusResponse(response);
// TODO: some weird naming clash hence getAccountTransactionsa
const getAccountTransactions = await getAccountTransactionsa();
setAccountTransactionResponse(getAccountTransactions);
} catch (err) {
console.log(err);
}
})();
}, []);
// populate customer payment data
React.useEffect(() => {
(async function() {
try {
// get card payments customer has made
let customerTransactionResponse = await getPaymentHistory();
customerTransactionResponse.reverse();
setCustomerTransactions(customerTransactionResponse);
} catch (err) {
console.log(err);
}
})();
}, []);
// @endif // @endif
const { totalBalance } = props; const { totalBalance } = props;
@ -161,11 +86,15 @@ const WalletPage = (props: Props) => {
<Page> <Page>
<Tabs onChange={onTabChange} index={tabIndex}> <Tabs onChange={onTabChange} index={tabIndex}>
<TabList className="tabs__list--collection-edit-page"> <TabList className="tabs__list--collection-edit-page">
<Tab>{__('LBRY Credits')}</Tab> <Tab>{__('Balance')}</Tab>
<Tab>{__('Account History')}</Tab> <Tab>{__('Transactions')}</Tab>
<Tab>{__('Payment History')}</Tab>
</TabList> </TabList>
<TabPanels> <TabPanels>
{/* balances for lbc and fiat */}
<TabPanel>
<WalletBalance />
</TabPanel>
{/* transactions panel */}
<TabPanel> <TabPanel>
<div className="section card-stack"> <div className="section card-stack">
<div className="lbc-transactions"> <div className="lbc-transactions">
@ -182,7 +111,6 @@ const WalletPage = (props: Props) => {
<YrblWalletEmpty includeWalletLink /> <YrblWalletEmpty includeWalletLink />
) : ( ) : (
<div className="card-stack"> <div className="card-stack">
<WalletBalance />
<TxoList search={search} /> <TxoList search={search} />
</div> </div>
)} )}
@ -191,18 +119,6 @@ const WalletPage = (props: Props) => {
</div> </div>
</div> </div>
</TabPanel> </TabPanel>
<TabPanel>
<div className="section card-stack">
<WalletFiatBalance accountDetails={accountStatusResponse} />
<WalletFiatAccountHistory transactions={accountTransactionResponse} />
</div>
</TabPanel>
<TabPanel>
<div className="section card-stack">
<WalletFiatPaymentBalance transactions={customerTransactions} accountDetails={accountStatusResponse} />
<WalletFiatPaymentHistory transactions={customerTransactions} />
</div>
</TabPanel>
</TabPanels> </TabPanels>
</Tabs> </Tabs>
</Page> </Page>
@ -220,7 +136,6 @@ const WalletPage = (props: Props) => {
<YrblWalletEmpty includeWalletLink /> <YrblWalletEmpty includeWalletLink />
) : ( ) : (
<div className="card-stack"> <div className="card-stack">
<WalletBalance />
<TxoList search={search} /> <TxoList search={search} />
</div> </div>
)} )}