Compare commits
12 commits
master
...
wallet-ite
Author | SHA1 | Date | |
---|---|---|---|
|
4cd9062cfc | ||
|
29cec219d3 | ||
|
8c9af6aa1d | ||
|
32e6762ba8 | ||
|
815799a389 | ||
|
32e8672be5 | ||
|
78acb8d570 | ||
|
ab07b45e05 | ||
|
0df1852f5d | ||
|
d80182f91d | ||
|
f1715660f8 | ||
|
b3d3a1a454 |
7 changed files with 383 additions and 292 deletions
|
@ -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;
|
||||||
|
|
||||||
|
|
|
@ -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>
|
||||||
|
</fieldset-section>
|
||||||
</div>
|
</div>
|
||||||
<Button button="alt" icon={ICONS.REFRESH} label={__('Refresh')} onClick={() => fetchTxoPage()} />
|
</>
|
||||||
</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>
|
||||||
}
|
}
|
||||||
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -21,67 +21,60 @@ 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
|
<div className="table__wrapper">
|
||||||
title={'Tip History'}
|
<table className="table table--transactions">
|
||||||
body={(
|
<thead>
|
||||||
<>
|
<tr>
|
||||||
<div className="table__wrapper">
|
<th className="date-header">{__('Date')}</th>
|
||||||
<table className="table table--transactions">
|
<th>{<>{__('Receiving Channel Name')}</>}</th>
|
||||||
<thead>
|
<th>{__('Tip Location')}</th>
|
||||||
<tr>
|
<th>{__('Amount (USD)')} </th>
|
||||||
<th className="date-header">{__('Date')}</th>
|
<th>{__('Processing Fee')}</th>
|
||||||
<th>{<>{__('Receiving Channel Name')}</>}</th>
|
<th>{__('Odysee Fee')}</th>
|
||||||
<th>{__('Tip Location')}</th>
|
<th>{__('Received Amount')}</th>
|
||||||
<th>{__('Amount (USD)')} </th>
|
</tr>
|
||||||
<th>{__('Processing Fee')}</th>
|
</thead>
|
||||||
<th>{__('Odysee Fee')}</th>
|
<tbody>
|
||||||
<th>{__('Received Amount')}</th>
|
{accountTransactions &&
|
||||||
</tr>
|
accountTransactions.map((transaction) => (
|
||||||
</thead>
|
<tr key={transaction.name + transaction.created_at}>
|
||||||
<tbody>
|
<td>{moment(transaction.created_at).format('LLL')}</td>
|
||||||
{accountTransactions &&
|
<td>
|
||||||
accountTransactions.map((transaction) => (
|
<Button
|
||||||
<tr key={transaction.name + transaction.created_at}>
|
className=""
|
||||||
<td>{moment(transaction.created_at).format('LLL')}</td>
|
navigate={'/' + transaction.channel_name + ':' + transaction.channel_claim_id}
|
||||||
<td>
|
label={transaction.channel_name}
|
||||||
<Button
|
button="link"
|
||||||
className=""
|
/>
|
||||||
navigate={'/' + transaction.channel_name + ':' + transaction.channel_claim_id}
|
</td>
|
||||||
label={transaction.channel_name}
|
<td>
|
||||||
button="link"
|
<Button
|
||||||
/>
|
className=""
|
||||||
</td>
|
navigate={'/' + transaction.channel_name + ':' + transaction.source_claim_id}
|
||||||
<td>
|
label={
|
||||||
<Button
|
transaction.channel_claim_id === transaction.source_claim_id
|
||||||
className=""
|
? 'Channel Page'
|
||||||
navigate={'/' + transaction.channel_name + ':' + transaction.source_claim_id}
|
: 'Content Page'
|
||||||
label={
|
}
|
||||||
transaction.channel_claim_id === transaction.source_claim_id
|
button="link"
|
||||||
? 'Channel Page'
|
/>
|
||||||
: 'Content Page'
|
</td>
|
||||||
}
|
<td>${transaction.tipped_amount / 100}</td>
|
||||||
button="link"
|
<td>${transaction.transaction_fee / 100}</td>
|
||||||
/>
|
<td>${transaction.application_fee / 100}</td>
|
||||||
</td>
|
<td>${transaction.received_amount / 100}</td>
|
||||||
<td>${transaction.tipped_amount / 100}</td>
|
</tr>
|
||||||
<td>${transaction.transaction_fee / 100}</td>
|
))}
|
||||||
<td>${transaction.application_fee / 100}</td>
|
</tbody>
|
||||||
<td>${transaction.received_amount / 100}</td>
|
</table>
|
||||||
</tr>
|
{!accountTransactions && <p style={{textAlign: 'center', marginTop: '20px', fontSize: '13px', color: 'rgb(171, 171, 171)'}}>No Transactions</p>}
|
||||||
))}
|
</div>
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
{!accountTransactions && <p style={{textAlign: 'center', marginTop: '20px', fontSize: '13px', color: 'rgb(171, 171, 171)'}}>No Transactions</p>}
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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>
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -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,59 +47,64 @@ const WalletBalance = (props: Props) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Card
|
<div className="section card-stack">
|
||||||
title={__('Payment History')}
|
<div className="table__wrapper">
|
||||||
body={
|
<table className="table table--transactions">
|
||||||
<>
|
{/* table header */}
|
||||||
<div className="table__wrapper">
|
<thead>
|
||||||
<table className="table table--transactions">
|
<tr>
|
||||||
<thead>
|
<th className="date-header">{__('Date')}</th>
|
||||||
<tr>
|
<th>{<>{__('Receiving Channel Name')}</>}</th>
|
||||||
<th className="date-header">{__('Date')}</th>
|
<th>{__('Tip Location')}</th>
|
||||||
<th>{<>{__('Receiving Channel Name')}</>}</th>
|
<th>{__('Amount (USD)')} </th>
|
||||||
<th>{__('Tip Location')}</th>
|
<th>{__('Card Last 4')}</th>
|
||||||
<th>{__('Amount (USD)')} </th>
|
<th>{__('Anonymous')}</th>
|
||||||
<th>{__('Card Last 4')}</th>
|
</tr>
|
||||||
<th>{__('Anonymous')}</th>
|
</thead>
|
||||||
</tr>
|
{/* list data for transactions */}
|
||||||
</thead>
|
<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>
|
||||||
<td>
|
{/* receiving channel name */}
|
||||||
<Button
|
<td>
|
||||||
className=""
|
<Button
|
||||||
navigate={'/' + transaction.channel_name + ':' + transaction.channel_claim_id}
|
className=""
|
||||||
label={transaction.channel_name}
|
navigate={'/' + transaction.channel_name + ':' + transaction.channel_claim_id}
|
||||||
button="link"
|
label={transaction.channel_name}
|
||||||
/>
|
button="link"
|
||||||
</td>
|
/>
|
||||||
<td>
|
</td>
|
||||||
<Button
|
{/* link to content or channel */}
|
||||||
className=""
|
<td>
|
||||||
navigate={'/' + transaction.channel_name + ':' + transaction.source_claim_id}
|
<Button
|
||||||
label={
|
className=""
|
||||||
transaction.channel_claim_id === transaction.source_claim_id
|
navigate={'/' + transaction.channel_name + ':' + transaction.source_claim_id}
|
||||||
? 'Channel Page'
|
label={
|
||||||
: 'Content Page'
|
transaction.channel_claim_id === transaction.source_claim_id
|
||||||
}
|
? 'Channel Page'
|
||||||
button="link"
|
: 'Content Page'
|
||||||
/>
|
}
|
||||||
</td>
|
button="link"
|
||||||
<td>${transaction.tipped_amount / 100}</td>
|
/>
|
||||||
<td>{lastFour}</td>
|
</td>
|
||||||
<td>{transaction.private_tip ? 'Yes' : 'No'}</td>
|
{/* how much tipped */}
|
||||||
</tr>
|
<td>${transaction.tipped_amount / 100}</td>
|
||||||
))}
|
{/* TODO: this is incorrect need it per transactions not per user */}
|
||||||
</tbody>
|
{/* last four of credit card */}
|
||||||
</table>
|
<td>{lastFour}</td>
|
||||||
{(!accountTransactions || accountTransactions.length === 0) && <p style={{textAlign: 'center', marginTop: '20px', fontSize: '13px', color: 'rgb(171, 171, 171)'}}>No Transactions</p>}
|
{/* whether tip is anonymous or not */}
|
||||||
</div>
|
<td>{transaction.private_tip ? 'Yes' : 'No'}</td>
|
||||||
</>
|
</tr>
|
||||||
}
|
))}
|
||||||
/>
|
</tbody>
|
||||||
|
</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>}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -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>
|
||||||
)}
|
)}
|
||||||
|
|
Loading…
Reference in a new issue