import { FunctionComponent } from 'react' import { Table, Thead, Tbody, Tr, Th, Td } from 'react-super-responsive-table' import { ArrowSmDownIcon, ExternalLinkIcon } from '@heroicons/react/outline' import { useSortableData } from '../hooks/useSortableData' import { LinkButton } from './Button' import useMangoStore from '../stores/useMangoStore' import { tokenPrecision } from '../utils' interface DepositWithdrawHistoryTableProps { type: 'deposits' | 'withdrawals' } const DepositWithdrawHistoryTable: FunctionComponent = ({ type }) => { const depositHistory = useMangoStore((s) => s.depositHistory) const withdrawalHistory = useMangoStore((s) => s.withdrawalHistory) const history = type === 'deposits' ? depositHistory : withdrawalHistory const { items, requestSort, sortConfig } = useSortableData(history) const renderTransactionTime = (timestamp) => { const date = new Date(timestamp) return ( <>
{date.toLocaleDateString()}
{date.toLocaleTimeString()}
) } return (
{history.length > 0 ? (
{items.map((transaction, index) => ( ))}
requestSort('block_time')} > Date/Time requestSort('symbol')} > Asset requestSort('quantity')} > Quantity requestSort('usd_equivalent')} > Value
{renderTransactionTime(transaction.block_datetime)}
{transaction.symbol}
{transaction.quantity.toLocaleString(undefined, { maximumFractionDigits: tokenPrecision[transaction.symbol], })} $ {transaction.usd_equivalent.toLocaleString( undefined, { maximumFractionDigits: 2, } )} View Transaction
) : (
{type === 'deposits' ? 'No deposits' : 'No withdrawals'}
)}
) } export default DepositWithdrawHistoryTable