import { ArrowSmDownIcon } from '@heroicons/react/solid' 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) => { const date = new Date(timestamp) return ( <>
{date.toLocaleDateString()}
{date.toLocaleTimeString()}
) } return (
{tradeHistory && tradeHistory.length ? (
{items.map((trade, 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 Date
{trade.marketName}
{trade.size} {trade.price} ${(trade.price * trade.size).toFixed(2)} {trade.liquidity} {trade.feeCost} {trade.loadTimestamp ? renderTradeDateTime(trade.loadTimestamp) : 'Recent'}
) : (
No {marketConfig.name} trade history. {asPath === '/account' ? ( Make a trade ) : null}
)}
) } export default TradeHistoryTable