2020-04-10 19:31:36 +02:00
|
|
|
// @flow
|
2020-06-02 18:32:58 +02:00
|
|
|
import * as ICONS from 'constants/icons';
|
2020-04-10 19:31:36 +02:00
|
|
|
import React, { useEffect } from 'react';
|
|
|
|
import { withRouter } from 'react-router';
|
|
|
|
import { TXO_LIST as TXO } from 'lbry-redux';
|
|
|
|
import TransactionListTable from 'component/transactionListTable';
|
|
|
|
import Paginate from 'component/common/paginate';
|
|
|
|
import { FormField } from 'component/common/form-components/form-field';
|
|
|
|
import Button from 'component/button';
|
|
|
|
import Card from 'component/common/card';
|
|
|
|
import { toCapitalCase } from 'util/string';
|
|
|
|
import classnames from 'classnames';
|
2020-04-21 16:18:54 +02:00
|
|
|
import HelpLink from 'component/common/help-link';
|
2021-04-23 18:10:37 +02:00
|
|
|
import FileExporter from 'component/common/file-exporter';
|
2021-08-18 20:06:12 +02:00
|
|
|
import WalletFiatPaymentHistory from 'component/walletFiatPaymentHistory';
|
|
|
|
import WalletFiatAccountHistory from 'component/walletFiatAccountHistory';
|
|
|
|
import { Lbryio } from 'lbryinc';
|
2021-08-20 17:06:04 +02:00
|
|
|
import { getStripeEnvironment } from 'util/stripe';
|
|
|
|
let stripeEnvironment = getStripeEnvironment();
|
2021-08-18 20:06:12 +02:00
|
|
|
|
2021-08-20 17:06:04 +02:00
|
|
|
// constants to be used in query params
|
2021-08-20 17:39:33 +02:00
|
|
|
const QUERY_NAME_CURRENCY = 'currency';
|
|
|
|
const QUERY_NAME_TAB = 'tab';
|
|
|
|
const QUERY_NAME_FIAT_TYPE = 'fiatType';
|
|
|
|
// TODO: this tab will be renamed
|
|
|
|
const DEFAULT_CURRENCY_PARAM = 'credits';
|
|
|
|
const DEFAULT_TAB_PARAM = 'fiat-payment-history';
|
|
|
|
const DEFAULT_FIAT_TYPE_PARAM = 'incoming';
|
2020-04-10 19:31:36 +02:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
search: string,
|
2021-04-23 18:10:37 +02:00
|
|
|
history: { action: string, push: (string) => void, replace: (string) => void },
|
2020-04-10 19:31:36 +02:00
|
|
|
txoPage: Array<Transaction>,
|
|
|
|
txoPageNumber: string,
|
|
|
|
txoItemCount: number,
|
|
|
|
fetchTxoPage: () => void,
|
2021-04-23 18:10:37 +02:00
|
|
|
fetchTransactions: () => void,
|
|
|
|
isFetchingTransactions: boolean,
|
|
|
|
transactionsFile: string,
|
|
|
|
updateTxoPageParams: (any) => void,
|
|
|
|
toast: (string, boolean) => void,
|
2020-04-10 19:31:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
type Delta = {
|
2021-08-20 19:31:38 +02:00
|
|
|
changedParameterKey: string,
|
|
|
|
value: string,
|
2020-04-10 19:31:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
function TxoList(props: Props) {
|
2021-04-23 18:10:37 +02:00
|
|
|
const {
|
|
|
|
search,
|
|
|
|
txoPage,
|
|
|
|
txoItemCount,
|
|
|
|
fetchTxoPage,
|
|
|
|
fetchTransactions,
|
|
|
|
updateTxoPageParams,
|
|
|
|
history,
|
|
|
|
isFetchingTransactions,
|
|
|
|
transactionsFile,
|
|
|
|
} = props;
|
2020-04-10 19:31:36 +02:00
|
|
|
|
2021-08-18 20:06:12 +02:00
|
|
|
const [accountTransactionResponse, setAccountTransactionResponse] = React.useState([]);
|
|
|
|
const [customerTransactions, setCustomerTransactions] = React.useState([]);
|
|
|
|
|
|
|
|
function getPaymentHistory() {
|
|
|
|
return Lbryio.call(
|
|
|
|
'customer',
|
|
|
|
'list',
|
|
|
|
{
|
|
|
|
environment: stripeEnvironment,
|
|
|
|
},
|
|
|
|
'post'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-08-19 22:23:20 +02:00
|
|
|
function getAccountTransactions() {
|
2021-08-18 20:06:12 +02:00
|
|
|
return Lbryio.call(
|
|
|
|
'account',
|
|
|
|
'list',
|
|
|
|
{
|
|
|
|
environment: stripeEnvironment,
|
|
|
|
},
|
|
|
|
'post'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// calculate account transactions section
|
|
|
|
React.useEffect(() => {
|
2021-08-27 07:07:16 +02:00
|
|
|
(async function () {
|
2021-08-18 20:06:12 +02:00
|
|
|
try {
|
2021-08-19 22:23:20 +02:00
|
|
|
const accountTransactionResponse = await getAccountTransactions();
|
2021-08-18 20:06:12 +02:00
|
|
|
|
2021-08-23 20:34:54 +02:00
|
|
|
// reverse so order is from most recent to latest
|
|
|
|
if (accountTransactionResponse && accountTransactionResponse.length) {
|
|
|
|
accountTransactionResponse.reverse();
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: remove this once pagination is implemented
|
|
|
|
if (accountTransactionResponse && accountTransactionResponse.length && accountTransactionResponse.length > 25) {
|
|
|
|
accountTransactionResponse.length = 25;
|
|
|
|
}
|
|
|
|
|
2021-08-19 22:23:20 +02:00
|
|
|
setAccountTransactionResponse(accountTransactionResponse);
|
2021-08-18 20:06:12 +02:00
|
|
|
} catch (err) {
|
|
|
|
console.log(err);
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
// populate customer payment data
|
|
|
|
React.useEffect(() => {
|
2021-08-27 07:07:16 +02:00
|
|
|
(async function () {
|
2021-08-18 20:06:12 +02:00
|
|
|
try {
|
|
|
|
// get card payments customer has made
|
|
|
|
let customerTransactionResponse = await getPaymentHistory();
|
|
|
|
// console.log('amount of transactions');
|
|
|
|
// console.log(customerTransactionResponse.length);
|
|
|
|
|
2021-08-23 20:34:54 +02:00
|
|
|
// reverse so order is from most recent to latest
|
2021-08-18 20:06:12 +02:00
|
|
|
if (customerTransactionResponse && customerTransactionResponse.length) {
|
|
|
|
customerTransactionResponse.reverse();
|
|
|
|
}
|
|
|
|
|
2021-08-23 20:34:54 +02:00
|
|
|
// TODO: remove this once pagination is implemented
|
2021-08-27 07:07:16 +02:00
|
|
|
if (
|
|
|
|
customerTransactionResponse &&
|
|
|
|
customerTransactionResponse.length &&
|
|
|
|
customerTransactionResponse.length > 25
|
|
|
|
) {
|
2021-08-23 20:34:54 +02:00
|
|
|
customerTransactionResponse.length = 25;
|
|
|
|
}
|
|
|
|
|
2021-08-18 20:06:12 +02:00
|
|
|
setCustomerTransactions(customerTransactionResponse);
|
|
|
|
} catch (err) {
|
|
|
|
console.log(err);
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
}, []);
|
|
|
|
|
2020-04-10 19:31:36 +02:00
|
|
|
const urlParams = new URLSearchParams(search);
|
|
|
|
const page = urlParams.get(TXO.PAGE) || String(1);
|
|
|
|
const pageSize = urlParams.get(TXO.PAGE_SIZE) || String(TXO.PAGE_SIZE_DEFAULT);
|
2020-04-15 20:09:22 +02:00
|
|
|
const type = urlParams.get(TXO.TYPE) || TXO.ALL;
|
2020-04-10 19:31:36 +02:00
|
|
|
const subtype = urlParams.get(TXO.SUB_TYPE);
|
2020-04-15 20:09:22 +02:00
|
|
|
const active = urlParams.get(TXO.ACTIVE) || TXO.ALL;
|
2021-08-20 17:39:33 +02:00
|
|
|
const currency = urlParams.get(QUERY_NAME_CURRENCY) || DEFAULT_CURRENCY_PARAM;
|
|
|
|
const fiatType = urlParams.get(QUERY_NAME_FIAT_TYPE) || DEFAULT_FIAT_TYPE_PARAM;
|
2021-08-20 17:06:04 +02:00
|
|
|
// tab used in the wallet section
|
|
|
|
// TODO: need to change this eventually
|
2021-08-20 17:39:33 +02:00
|
|
|
const tab = urlParams.get(QUERY_NAME_TAB) || DEFAULT_TAB_PARAM;
|
2020-04-10 19:31:36 +02:00
|
|
|
|
|
|
|
const currentUrlParams = {
|
|
|
|
page,
|
|
|
|
pageSize,
|
|
|
|
active,
|
|
|
|
type,
|
|
|
|
subtype,
|
2021-08-18 20:06:12 +02:00
|
|
|
currency,
|
|
|
|
fiatType,
|
2021-08-20 17:39:33 +02:00
|
|
|
tab,
|
2020-04-10 19:31:36 +02:00
|
|
|
};
|
|
|
|
|
2020-04-16 22:25:15 +02:00
|
|
|
const hideStatus =
|
2020-04-17 18:06:49 +02:00
|
|
|
type === TXO.SENT || (currentUrlParams.type === TXO.RECEIVED && currentUrlParams.subtype !== TXO.TIP);
|
2020-04-16 22:25:15 +02:00
|
|
|
|
2021-08-20 19:31:38 +02:00
|
|
|
// this is for sdk params
|
2020-04-10 19:31:36 +02:00
|
|
|
const params = {};
|
|
|
|
if (currentUrlParams.type) {
|
2020-04-15 20:09:22 +02:00
|
|
|
if (currentUrlParams.type === TXO.ALL) {
|
|
|
|
params[TXO.EXCLUDE_INTERNAL_TRANSFERS] = true;
|
2020-04-17 03:47:19 +02:00
|
|
|
params[TXO.IS_MY_INPUT_OR_OUTPUT] = true;
|
2020-04-15 20:09:22 +02:00
|
|
|
} else if (currentUrlParams.type === TXO.SENT) {
|
2020-04-10 19:31:36 +02:00
|
|
|
params[TXO.IS_MY_INPUT] = true;
|
|
|
|
params[TXO.IS_NOT_MY_OUTPUT] = true;
|
|
|
|
if (currentUrlParams.subtype === TXO.TIP) {
|
|
|
|
params[TXO.TX_TYPE] = TXO.SUPPORT;
|
|
|
|
} else if (currentUrlParams.subtype === TXO.PURCHASE) {
|
|
|
|
params[TXO.TX_TYPE] = TXO.PURCHASE;
|
2020-04-16 22:25:15 +02:00
|
|
|
} else if (currentUrlParams.subtype === TXO.PAYMENT) {
|
2020-04-10 19:31:36 +02:00
|
|
|
params[TXO.TX_TYPE] = TXO.OTHER;
|
|
|
|
} else {
|
|
|
|
params[TXO.TX_TYPE] = [TXO.OTHER, TXO.PURCHASE, TXO.SUPPORT];
|
|
|
|
}
|
|
|
|
} else if (currentUrlParams.type === TXO.RECEIVED) {
|
|
|
|
params[TXO.IS_MY_OUTPUT] = true;
|
|
|
|
params[TXO.IS_NOT_MY_INPUT] = true;
|
|
|
|
if (currentUrlParams.subtype === TXO.TIP) {
|
|
|
|
params[TXO.TX_TYPE] = TXO.SUPPORT;
|
|
|
|
} else if (currentUrlParams.subtype === TXO.PURCHASE) {
|
|
|
|
params[TXO.TX_TYPE] = TXO.PURCHASE;
|
2020-04-15 20:09:22 +02:00
|
|
|
} else if (currentUrlParams.subtype === TXO.PAYMENT) {
|
2020-04-10 19:31:36 +02:00
|
|
|
params[TXO.TX_TYPE] = TXO.OTHER;
|
2020-04-15 20:09:22 +02:00
|
|
|
params[TXO.EXCLUDE_INTERNAL_TRANSFERS] = true;
|
2020-04-10 19:31:36 +02:00
|
|
|
} else {
|
|
|
|
params[TXO.TX_TYPE] = [TXO.OTHER, TXO.PURCHASE, TXO.SUPPORT];
|
|
|
|
}
|
|
|
|
} else if (currentUrlParams.type === TXO.SUPPORT) {
|
|
|
|
params[TXO.TX_TYPE] = TXO.SUPPORT;
|
|
|
|
params[TXO.IS_MY_INPUT] = true;
|
|
|
|
params[TXO.IS_MY_OUTPUT] = true;
|
|
|
|
} else if (currentUrlParams.type === TXO.CHANNEL || currentUrlParams.type === TXO.REPOST) {
|
|
|
|
params[TXO.TX_TYPE] = currentUrlParams.type;
|
|
|
|
} else if (currentUrlParams.type === TXO.PUBLISH) {
|
|
|
|
params[TXO.TX_TYPE] = TXO.STREAM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (currentUrlParams.active) {
|
|
|
|
if (currentUrlParams.active === 'spent') {
|
|
|
|
params[TXO.IS_SPENT] = true;
|
|
|
|
} else if (currentUrlParams.active === 'active') {
|
|
|
|
params[TXO.IS_NOT_SPENT] = true;
|
|
|
|
}
|
|
|
|
}
|
2020-04-16 22:25:15 +02:00
|
|
|
|
2020-04-10 19:31:36 +02:00
|
|
|
if (currentUrlParams.page) params[TXO.PAGE] = Number(page);
|
|
|
|
if (currentUrlParams.pageSize) params[TXO.PAGE_SIZE] = Number(pageSize);
|
|
|
|
|
|
|
|
function handleChange(delta: Delta) {
|
|
|
|
const url = updateUrl(delta);
|
|
|
|
history.push(url);
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateUrl(delta: Delta) {
|
|
|
|
const newUrlParams = new URLSearchParams();
|
2021-08-18 20:06:12 +02:00
|
|
|
|
2021-08-20 19:31:38 +02:00
|
|
|
switch (delta.changedParameterKey) {
|
2020-04-10 19:31:36 +02:00
|
|
|
case TXO.PAGE:
|
|
|
|
if (currentUrlParams.type) {
|
|
|
|
newUrlParams.set(TXO.TYPE, currentUrlParams.type);
|
|
|
|
}
|
|
|
|
if (currentUrlParams.subtype) {
|
|
|
|
newUrlParams.set(TXO.SUB_TYPE, currentUrlParams.subtype);
|
|
|
|
}
|
|
|
|
if (currentUrlParams.active) {
|
|
|
|
newUrlParams.set(TXO.ACTIVE, currentUrlParams.active);
|
|
|
|
}
|
|
|
|
newUrlParams.set(TXO.PAGE, delta.value);
|
2021-08-20 19:31:38 +02:00
|
|
|
newUrlParams.set(QUERY_NAME_TAB, currentUrlParams.tab);
|
|
|
|
newUrlParams.set(QUERY_NAME_CURRENCY, currentUrlParams.currency);
|
2020-04-10 19:31:36 +02:00
|
|
|
break;
|
|
|
|
case TXO.TYPE:
|
|
|
|
newUrlParams.set(TXO.TYPE, delta.value);
|
|
|
|
if (delta.value === TXO.SENT || delta.value === TXO.RECEIVED) {
|
2020-04-16 22:25:15 +02:00
|
|
|
newUrlParams.set(TXO.ACTIVE, 'all');
|
2020-04-10 19:31:36 +02:00
|
|
|
if (currentUrlParams.subtype) {
|
|
|
|
newUrlParams.set(TXO.SUB_TYPE, currentUrlParams.subtype);
|
|
|
|
} else {
|
|
|
|
newUrlParams.set(TXO.SUB_TYPE, 'all');
|
|
|
|
}
|
|
|
|
}
|
2020-04-17 17:20:48 +02:00
|
|
|
if (currentUrlParams.active && !hideStatus) {
|
2020-04-10 19:31:36 +02:00
|
|
|
newUrlParams.set(TXO.ACTIVE, currentUrlParams.active);
|
2020-04-17 03:47:10 +02:00
|
|
|
} else {
|
|
|
|
newUrlParams.set(TXO.ACTIVE, 'all');
|
2020-04-10 19:31:36 +02:00
|
|
|
}
|
|
|
|
newUrlParams.set(TXO.PAGE, String(1));
|
|
|
|
newUrlParams.set(TXO.PAGE_SIZE, currentUrlParams.pageSize);
|
2021-08-20 19:31:38 +02:00
|
|
|
newUrlParams.set(QUERY_NAME_TAB, currentUrlParams.tab);
|
|
|
|
newUrlParams.set(QUERY_NAME_CURRENCY, currentUrlParams.currency);
|
2020-04-10 19:31:36 +02:00
|
|
|
break;
|
|
|
|
case TXO.SUB_TYPE:
|
|
|
|
if (currentUrlParams.type) {
|
|
|
|
newUrlParams.set(TXO.TYPE, currentUrlParams.type);
|
|
|
|
}
|
2020-04-17 03:47:10 +02:00
|
|
|
newUrlParams.set(TXO.ACTIVE, 'all');
|
2020-04-10 19:31:36 +02:00
|
|
|
newUrlParams.set(TXO.SUB_TYPE, delta.value);
|
|
|
|
newUrlParams.set(TXO.PAGE, String(1));
|
|
|
|
newUrlParams.set(TXO.PAGE_SIZE, currentUrlParams.pageSize);
|
2021-08-20 19:31:38 +02:00
|
|
|
newUrlParams.set(QUERY_NAME_TAB, currentUrlParams.tab);
|
|
|
|
newUrlParams.set(QUERY_NAME_CURRENCY, currentUrlParams.currency);
|
2020-04-10 19:31:36 +02:00
|
|
|
break;
|
|
|
|
case TXO.ACTIVE:
|
|
|
|
if (currentUrlParams.type) {
|
|
|
|
newUrlParams.set(TXO.TYPE, currentUrlParams.type);
|
|
|
|
}
|
|
|
|
if (currentUrlParams.subtype) {
|
|
|
|
newUrlParams.set(TXO.SUB_TYPE, currentUrlParams.subtype);
|
|
|
|
}
|
|
|
|
newUrlParams.set(TXO.ACTIVE, delta.value);
|
|
|
|
newUrlParams.set(TXO.PAGE, String(1));
|
|
|
|
newUrlParams.set(TXO.PAGE_SIZE, currentUrlParams.pageSize);
|
2021-08-20 19:31:38 +02:00
|
|
|
newUrlParams.set(QUERY_NAME_TAB, currentUrlParams.tab);
|
|
|
|
newUrlParams.set(QUERY_NAME_CURRENCY, currentUrlParams.currency);
|
|
|
|
break;
|
|
|
|
// toggling the currency type (lbc/fiat)
|
|
|
|
case QUERY_NAME_CURRENCY:
|
|
|
|
newUrlParams.set(QUERY_NAME_CURRENCY, delta.value);
|
|
|
|
newUrlParams.set(QUERY_NAME_TAB, currentUrlParams.tab);
|
2021-08-23 20:34:54 +02:00
|
|
|
// only set fiat type (incoming|outgoing) if fiat is being used
|
|
|
|
if (delta.value === 'credits') {
|
|
|
|
newUrlParams.delete(QUERY_NAME_FIAT_TYPE);
|
|
|
|
} else {
|
|
|
|
newUrlParams.set(QUERY_NAME_FIAT_TYPE, currentUrlParams.fiatType);
|
|
|
|
}
|
2021-08-20 19:31:38 +02:00
|
|
|
break;
|
|
|
|
// toggling the fiat type (incoming/outgoing)
|
|
|
|
case QUERY_NAME_FIAT_TYPE:
|
|
|
|
newUrlParams.set(QUERY_NAME_FIAT_TYPE, delta.value);
|
|
|
|
newUrlParams.set(QUERY_NAME_TAB, currentUrlParams.tab);
|
|
|
|
newUrlParams.set(QUERY_NAME_CURRENCY, currentUrlParams.currency);
|
2020-04-10 19:31:36 +02:00
|
|
|
break;
|
|
|
|
}
|
2020-04-17 17:20:48 +02:00
|
|
|
|
2020-04-10 19:31:36 +02:00
|
|
|
return `?${newUrlParams.toString()}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
const paramsString = JSON.stringify(params);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (paramsString && updateTxoPageParams) {
|
|
|
|
const params = JSON.parse(paramsString);
|
|
|
|
updateTxoPageParams(params);
|
|
|
|
}
|
|
|
|
}, [paramsString, updateTxoPageParams]);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Card
|
2021-08-18 20:06:12 +02:00
|
|
|
title={
|
2021-08-27 07:07:16 +02:00
|
|
|
<>
|
|
|
|
<div className="table__header-text txo__table_header">{__(`Transactions`)}</div>
|
2021-08-23 18:30:12 +02:00
|
|
|
<div className="txo__radios_container">
|
2021-08-27 07:07:16 +02:00
|
|
|
<fieldset-section style={{ display: 'inline' }} className="txo__radios_fieldset">
|
2021-08-20 20:48:28 +02:00
|
|
|
{/* toggle between LBC and fiat buttons */}
|
2021-08-23 18:30:12 +02:00
|
|
|
<div className={'txo__radios'}>
|
2021-08-20 20:48:28 +02:00
|
|
|
{/* toggle to LBC */}
|
2021-08-18 20:06:12 +02:00
|
|
|
<Button
|
|
|
|
button="alt"
|
2021-08-20 19:31:38 +02:00
|
|
|
onClick={(e) => handleChange({ changedParameterKey: QUERY_NAME_CURRENCY, value: 'credits' })}
|
2021-08-18 20:06:12 +02:00
|
|
|
className={classnames(`button-toggle`, {
|
|
|
|
'button-toggle--active': currency === 'credits',
|
|
|
|
})}
|
2021-08-27 06:42:23 +02:00
|
|
|
label={__('Credits --[transactions tab]--')}
|
2021-08-18 20:06:12 +02:00
|
|
|
/>
|
2021-08-20 20:48:28 +02:00
|
|
|
{/* toggle to fiat */}
|
2021-08-18 20:06:12 +02:00
|
|
|
<Button
|
|
|
|
button="alt"
|
2021-08-20 19:31:38 +02:00
|
|
|
onClick={(e) => handleChange({ changedParameterKey: QUERY_NAME_CURRENCY, value: 'fiat' })}
|
2021-08-18 20:06:12 +02:00
|
|
|
className={classnames(`button-toggle`, {
|
|
|
|
'button-toggle--active': currency === 'fiat',
|
|
|
|
})}
|
2021-08-27 06:42:23 +02:00
|
|
|
label={__('USD --[transactions tab]--')}
|
2021-08-18 20:06:12 +02:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</fieldset-section>
|
2021-04-23 18:10:37 +02:00
|
|
|
</div>
|
2021-08-18 20:06:12 +02:00
|
|
|
</>
|
|
|
|
}
|
2020-04-29 21:31:11 +02:00
|
|
|
isBodyList
|
2021-08-27 07:07:16 +02:00
|
|
|
body={
|
|
|
|
currency === 'credits' ? (
|
|
|
|
<div>
|
|
|
|
{/* LBC transactions section */}
|
|
|
|
<div className="card__body-actions">
|
|
|
|
<div className="card__actions card__actions--between">
|
|
|
|
<div className="card__actions--inline">
|
2021-08-20 20:48:28 +02:00
|
|
|
<div>
|
2021-08-27 07:07:16 +02:00
|
|
|
{/* LBC transaction type dropdown */}
|
2021-08-20 20:48:28 +02:00
|
|
|
<FormField
|
|
|
|
type="select"
|
2021-08-27 07:07:16 +02:00
|
|
|
name="type"
|
|
|
|
label={
|
|
|
|
<>
|
|
|
|
{__('Type')}
|
|
|
|
<HelpLink href="https://lbry.com/faq/transaction-types" />
|
|
|
|
</>
|
|
|
|
}
|
|
|
|
value={type || 'all'}
|
|
|
|
onChange={(e) => handleChange({ changedParameterKey: TXO.TYPE, value: e.target.value, tab })}
|
2021-08-20 20:48:28 +02:00
|
|
|
>
|
2021-08-27 07:07:16 +02:00
|
|
|
{Object.values(TXO.DROPDOWN_TYPES).map((v) => {
|
2021-08-20 20:48:28 +02:00
|
|
|
const stringV = String(v);
|
|
|
|
return (
|
|
|
|
<option key={stringV} value={stringV}>
|
|
|
|
{stringV && __(toCapitalCase(stringV))}
|
|
|
|
</option>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</FormField>
|
|
|
|
</div>
|
2021-08-27 07:07:16 +02:00
|
|
|
{(type === TXO.SENT || type === TXO.RECEIVED) && (
|
|
|
|
<div>
|
|
|
|
<FormField
|
|
|
|
type="select"
|
|
|
|
name="subtype"
|
|
|
|
label={__('Payment Type')}
|
|
|
|
value={subtype || 'all'}
|
|
|
|
onChange={(e) =>
|
|
|
|
handleChange({ changedParameterKey: TXO.SUB_TYPE, value: e.target.value, tab })
|
|
|
|
}
|
|
|
|
>
|
|
|
|
{Object.values(TXO.DROPDOWN_SUBTYPES).map((v) => {
|
|
|
|
const stringV = String(v);
|
|
|
|
return (
|
|
|
|
<option key={stringV} value={stringV}>
|
|
|
|
{stringV && __(toCapitalCase(stringV))}
|
|
|
|
</option>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</FormField>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
{!hideStatus && (
|
|
|
|
<div>
|
|
|
|
<fieldset-section>
|
|
|
|
<label>{__('Status')}</label>
|
|
|
|
<div className={'txo__radios'}>
|
|
|
|
{/* active transactions button */}
|
|
|
|
<Button
|
|
|
|
button="alt"
|
|
|
|
onClick={(e) => handleChange({ changedParameterKey: TXO.ACTIVE, value: 'active' })}
|
|
|
|
className={classnames(`button-toggle`, {
|
|
|
|
'button-toggle--active': active === TXO.ACTIVE,
|
|
|
|
})}
|
|
|
|
label={__('Active')}
|
|
|
|
/>
|
|
|
|
{/* historical transactions button */}
|
|
|
|
<Button
|
|
|
|
button="alt"
|
|
|
|
onClick={(e) => handleChange({ changedParameterKey: TXO.ACTIVE, value: 'spent' })}
|
|
|
|
className={classnames(`button-toggle`, {
|
|
|
|
'button-toggle--active': active === 'spent',
|
|
|
|
})}
|
|
|
|
label={__('Historical')}
|
|
|
|
/>
|
|
|
|
{/* all transactions button */}
|
|
|
|
<Button
|
|
|
|
button="alt"
|
|
|
|
onClick={(e) => handleChange({ changedParameterKey: TXO.ACTIVE, value: 'all' })}
|
|
|
|
className={classnames(`button-toggle`, {
|
|
|
|
'button-toggle--active': active === 'all',
|
|
|
|
})}
|
|
|
|
label={__('All')}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</fieldset-section>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
{/* export and refresh buttons */}
|
|
|
|
<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>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{/* listing of the lbc transactions */}
|
|
|
|
<TransactionListTable txos={txoPage} />
|
|
|
|
<Paginate totalPages={Math.ceil(txoItemCount / Number(pageSize))} />
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<div>
|
|
|
|
{/* FIAT SECTION ( toggle buttons and transactions) */}
|
|
|
|
<div className="section card-stack">
|
|
|
|
<div className="card__body-actions">
|
|
|
|
<div className="card__actions">
|
2021-08-20 20:48:28 +02:00
|
|
|
<div>
|
|
|
|
<fieldset-section>
|
2021-08-27 07:07:16 +02:00
|
|
|
<label>{__('Type')}</label>
|
2021-08-20 20:48:28 +02:00
|
|
|
<div className={'txo__radios'}>
|
2021-08-27 07:07:16 +02:00
|
|
|
{/* incoming transactions button */}
|
2021-08-20 20:48:28 +02:00
|
|
|
<Button
|
|
|
|
button="alt"
|
2021-08-27 07:07:16 +02:00
|
|
|
onClick={(e) =>
|
|
|
|
handleChange({ changedParameterKey: QUERY_NAME_FIAT_TYPE, value: 'incoming' })
|
|
|
|
}
|
2021-08-20 20:48:28 +02:00
|
|
|
className={classnames(`button-toggle`, {
|
2021-08-27 07:07:16 +02:00
|
|
|
'button-toggle--active': fiatType === 'incoming',
|
2021-08-20 20:48:28 +02:00
|
|
|
})}
|
2021-08-27 07:07:16 +02:00
|
|
|
label={__('Incoming')}
|
2021-08-20 20:48:28 +02:00
|
|
|
/>
|
2021-08-27 07:07:16 +02:00
|
|
|
{/* incoming transactions button */}
|
2021-08-20 20:48:28 +02:00
|
|
|
<Button
|
|
|
|
button="alt"
|
2021-08-27 07:07:16 +02:00
|
|
|
onClick={(e) =>
|
|
|
|
handleChange({ changedParameterKey: QUERY_NAME_FIAT_TYPE, value: 'outgoing' })
|
|
|
|
}
|
2021-08-20 20:48:28 +02:00
|
|
|
className={classnames(`button-toggle`, {
|
2021-08-27 07:07:16 +02:00
|
|
|
'button-toggle--active': fiatType === 'outgoing',
|
2021-08-20 20:48:28 +02:00
|
|
|
})}
|
2021-08-27 07:07:16 +02:00
|
|
|
label={__('Outgoing')}
|
2021-08-20 20:48:28 +02:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</fieldset-section>
|
|
|
|
</div>
|
2021-08-20 17:06:04 +02:00
|
|
|
</div>
|
2021-08-18 20:06:12 +02:00
|
|
|
</div>
|
2021-08-27 07:07:16 +02:00
|
|
|
{/* 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))} /> */}
|
2021-08-18 20:06:12 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-08-27 07:07:16 +02:00
|
|
|
)
|
2020-04-10 19:31:36 +02:00
|
|
|
}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default withRouter(TxoList);
|