import { ArrowSmDownIcon } from '@heroicons/react/solid' import BN from 'bn.js' import useTradeHistory from '../hooks/useTradeHistory' import Link from 'next/link' import { useRouter } from 'next/router' import { Table, Thead, Tbody, Tr, Th, Td } from 'react-super-responsive-table' import SideBadge from './SideBadge' import { LinkButton } from './Button' import { useSortableData } from '../hooks/useSortableData' const TradeHistoryTable = () => { const { asPath } = useRouter() const tradeHistory = useTradeHistory({ excludePerpLiquidations: true }) const { items, requestSort, sortConfig } = useSortableData(tradeHistory) const renderTradeDateTime = (timestamp: BN | string) => { let date if (timestamp instanceof BN) { date = new Date(timestamp.toNumber() * 1000) } else { date = new Date(timestamp) } return ( <>
{date.toLocaleDateString()}
{date.toLocaleTimeString()}
) } return (
Total trades: {tradeHistory.length}
{tradeHistory && tradeHistory.length ? (
{items.map((trade: any, index) => ( ))}
requestSort('market')} > Market requestSort('side')} > Side requestSort('size')} > Size requestSort('price')} > Price requestSort('value')} > Value requestSort('liquidity')} > Liquidity requestSort('feeCost')} > Fee requestSort('loadTimestamp')} > Approx Time
{trade.marketName}
{trade.size} {trade.price} ${trade.value.toFixed(2)} {trade.liquidity} ${trade.feeCost} {trade.loadTimestamp || trade.timestamp ? renderTradeDateTime( trade.loadTimestamp || trade.timestamp ) : 'Recent'}
) : (
No trade history {asPath === '/account' ? ( Make a trade ) : null}
)}
) } export default TradeHistoryTable