lbry-desktop/ui/page/wallet/view.jsx

75 lines
2.4 KiB
React
Raw Normal View History

// @flow
2019-06-17 22:32:38 +02:00
import React from 'react';
import { withRouter } from 'react-router';
2019-06-17 22:32:38 +02:00
import WalletBalance from 'component/walletBalance';
import TxoList from 'component/txoList';
2019-06-17 22:32:38 +02:00
import Page from 'component/page';
2020-06-01 19:03:19 +02:00
import Spinner from 'component/spinner';
import YrblWalletEmpty from 'component/yrblWalletEmpty';
2019-06-17 22:32:38 +02:00
type Props = {
2021-07-03 20:32:06 +02:00
history: { action: string, push: (string) => void, replace: (string) => void },
location: { search: string, pathname: string },
totalBalance: ?number,
};
2019-06-17 22:32:38 +02:00
const WalletPage = (props: Props) => {
const { location, totalBalance } = props;
const { search } = location;
const showIntro = totalBalance === 0;
const loading = totalBalance === undefined;
2021-07-28 13:08:28 +02:00
const TAB_LBC_TRANSACTIONS = 'TabLBCTransactions';
const TAB_FIAT_TRANSACTIONS = 'TabFiatTransactions';
const [activeTab, setActiveTab] = React.useState(TAB_LBC_TRANSACTIONS);
return (
<Page>
2021-07-28 13:08:28 +02:00
{/* tabs to switch between fiat and lbc */}
<h2 style={{display: 'inline-block', paddingBottom: '14px', marginRight: '10px', textUnderlineOffset: '4px', textDecoration: 'underline'}}
onClick={() => {
document.getElementsByClassName('lbc-transactions')[0].style.display = 'inline';
document.getElementsByClassName('fiat-transactions')[0].style.display = 'none';
}}
>LBC Transactions</h2>
<h2 style={{display: 'inline-block'}}
onClick={() => {
document.getElementsByClassName('lbc-transactions')[0].style.display = 'none';
document.getElementsByClassName('fiat-transactions')[0].style.display = 'inline';
}}
>Fiat Transactions</h2>
<div className="lbc-transactions">
{/* if the transactions are loading */}
{ loading && (
<div className="main--empty">
<Spinner delayed />
</div>
)}
{/* when the transactions are finished loading */}
{ !loading && (
<>
{showIntro ? (
<YrblWalletEmpty includeWalletLink />
) : (
<div className="card-stack">
<WalletBalance />
<TxoList search={search} />
</div>
)}
</>
)}
</div>
{(
2020-06-01 19:03:19 +02:00
<>
2021-07-28 13:08:28 +02:00
<div className="fiat-transactions">
<h2>Here's your fiat transactions</h2>
</div>
2020-06-01 19:03:19 +02:00
</>
)}
</Page>
);
};
export default withRouter(WalletPage);