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' import useMangoStore from '../stores/useMangoStore' const TradeHistoryTable = () => { const { asPath } = useRouter() const tradeHistory = useTradeHistory() const { items, requestSort, sortConfig } = useSortableData(tradeHistory) const marketConfig = useMangoStore((s) => s.selectedMarket.config) 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 (
{tradeHistory && tradeHistory.length ? (
For selected market
{items.map((trade, index) => ( ))}
requestSort('side')} > Side requestSort('size')} > Size requestSort('price')} > Price requestSort('value')} > Value requestSort('liquidity')} > Liquidity requestSort('feeCost')} > Fee requestSort('loadTimestamp')} > Approx Time
{trade.size} {trade.price} ${trade.value.toFixed(2)} {trade.liquidity} ${trade.feeCost} {trade.loadTimestamp || trade.timestamp ? renderTradeDateTime( trade.loadTimestamp || trade.timestamp ) : 'Recent'}
) : (
No {marketConfig.name} trade history. {asPath === '/account' ? ( Make a trade ) : null}
)}
) } export default TradeHistoryTable