2020-04-10 19:31:36 +02:00
|
|
|
// @flow
|
2019-06-17 22:32:38 +02:00
|
|
|
import React from 'react';
|
2020-04-10 19:31:36 +02:00
|
|
|
import { withRouter } from 'react-router';
|
2019-06-17 22:32:38 +02:00
|
|
|
import WalletBalance from 'component/walletBalance';
|
2021-07-28 15:18:06 +02:00
|
|
|
import WalletFiatBalance from 'component/WalletFiatBalance';
|
2020-04-10 19:31:36 +02:00
|
|
|
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';
|
2020-08-26 19:19:03 +02:00
|
|
|
import YrblWalletEmpty from 'component/yrblWalletEmpty';
|
2019-06-17 22:32:38 +02:00
|
|
|
|
2020-04-10 19:31:36 +02:00
|
|
|
type Props = {
|
2021-07-03 20:32:06 +02:00
|
|
|
history: { action: string, push: (string) => void, replace: (string) => void },
|
2020-04-10 19:31:36 +02:00
|
|
|
location: { search: string, pathname: string },
|
2021-02-05 18:46:07 +01:00
|
|
|
totalBalance: ?number,
|
2020-04-10 19:31:36 +02:00
|
|
|
};
|
2019-06-17 22:32:38 +02:00
|
|
|
|
2020-04-10 19:31:36 +02:00
|
|
|
const WalletPage = (props: Props) => {
|
2021-07-28 13:35:53 +02:00
|
|
|
console.log(props);
|
|
|
|
|
|
|
|
const tab = new URLSearchParams(props.location.search).get('tab');
|
|
|
|
|
2021-07-28 15:18:06 +02:00
|
|
|
React.useEffect(() => {
|
|
|
|
// if (tab === 'currency') {
|
|
|
|
if (1 === 1) {
|
2021-07-28 13:35:53 +02:00
|
|
|
document.getElementsByClassName('lbc-transactions')[0].style.display = 'none';
|
|
|
|
document.getElementsByClassName('fiat-transactions')[0].style.display = 'inline';
|
|
|
|
|
|
|
|
document.getElementsByClassName('lbc-tab-switcher')[0].style.textDecoration = 'none';
|
|
|
|
document.getElementsByClassName('fiat-tab-switcher')[0].style.textDecoration = 'underline';
|
|
|
|
}
|
2021-07-28 15:18:06 +02:00
|
|
|
}, []);
|
2021-07-28 13:35:53 +02:00
|
|
|
|
2021-02-05 18:46:07 +01:00
|
|
|
const { location, totalBalance } = props;
|
2020-04-10 19:31:36 +02:00
|
|
|
const { search } = location;
|
2021-02-05 18:46:07 +01:00
|
|
|
const showIntro = totalBalance === 0;
|
|
|
|
const loading = totalBalance === undefined;
|
2020-04-10 19:31:36 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Page>
|
2021-07-28 13:08:28 +02:00
|
|
|
{/* tabs to switch between fiat and lbc */}
|
2021-07-28 13:35:53 +02:00
|
|
|
<h2 className="lbc-tab-switcher"
|
2021-07-28 15:18:06 +02:00
|
|
|
style={{display: 'inline-block', paddingBottom: '16px', marginRight: '14px', textUnderlineOffset: '4px', textDecoration: 'underline', fontSize: '18px', marginLeft: '3px'}}
|
2021-07-28 13:08:28 +02:00
|
|
|
onClick={() => {
|
|
|
|
document.getElementsByClassName('lbc-transactions')[0].style.display = 'inline';
|
|
|
|
document.getElementsByClassName('fiat-transactions')[0].style.display = 'none';
|
2021-07-28 13:35:53 +02:00
|
|
|
|
|
|
|
document.getElementsByClassName('lbc-tab-switcher')[0].style.textDecoration = 'underline';
|
|
|
|
document.getElementsByClassName('fiat-tab-switcher')[0].style.textDecoration = 'none';
|
2021-07-28 13:08:28 +02:00
|
|
|
}}
|
|
|
|
>LBC Transactions</h2>
|
2021-07-28 13:35:53 +02:00
|
|
|
<h2 className="fiat-tab-switcher"
|
|
|
|
style={{display: 'inline-block', textUnderlineOffset: '4px', fontSize: '18px'}}
|
2021-07-28 13:08:28 +02:00
|
|
|
onClick={() => {
|
|
|
|
document.getElementsByClassName('lbc-transactions')[0].style.display = 'none';
|
|
|
|
document.getElementsByClassName('fiat-transactions')[0].style.display = 'inline';
|
2021-07-28 13:35:53 +02:00
|
|
|
|
|
|
|
document.getElementsByClassName('lbc-tab-switcher')[0].style.textDecoration = 'none';
|
|
|
|
document.getElementsByClassName('fiat-tab-switcher')[0].style.textDecoration = 'underline';
|
2021-07-28 13:08:28 +02:00
|
|
|
}}
|
2021-07-28 15:18:06 +02:00
|
|
|
>USD Transactions</h2>
|
2021-07-28 13:08:28 +02:00
|
|
|
<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:35:53 +02:00
|
|
|
<div className="fiat-transactions" style={{display: 'none'}}>
|
2021-07-28 15:18:06 +02:00
|
|
|
<WalletFiatBalance />
|
2021-07-28 13:08:28 +02:00
|
|
|
</div>
|
2020-06-01 19:03:19 +02:00
|
|
|
</>
|
|
|
|
)}
|
2020-04-10 19:31:36 +02:00
|
|
|
</Page>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default withRouter(WalletPage);
|