2021-04-12 21:40:26 -07:00
|
|
|
import useTradeHistory from '../hooks/useTradeHistory'
|
2021-04-20 07:19:08 -07:00
|
|
|
import { Table, Thead, Tbody, Tr, Th, Td } from 'react-super-responsive-table'
|
|
|
|
import SideBadge from './SideBadge'
|
2021-04-15 10:52:25 -07:00
|
|
|
// import useMangoStore from '../stores/useMangoStore'
|
|
|
|
// import Loading from './Loading'
|
2021-04-07 14:49:37 -07:00
|
|
|
|
|
|
|
const TradeHistoryTable = () => {
|
2021-04-14 23:16:36 -07:00
|
|
|
const tradeHistory = useTradeHistory()
|
2021-04-15 10:52:25 -07:00
|
|
|
// const connected = useMangoStore((s) => s.wallet.connected)
|
2021-04-07 14:49:37 -07:00
|
|
|
|
|
|
|
return (
|
2021-04-12 09:49:02 -07:00
|
|
|
<div className={`flex flex-col py-6`}>
|
|
|
|
<div className={`-my-2 overflow-x-auto sm:-mx-6 lg:-mx-8`}>
|
|
|
|
<div className={`align-middle inline-block min-w-full sm:px-6 lg:px-8`}>
|
2021-04-13 09:57:58 -07:00
|
|
|
{tradeHistory && tradeHistory.length ? (
|
2021-04-07 14:49:37 -07:00
|
|
|
<div
|
2021-04-12 21:40:26 -07:00
|
|
|
className={`shadow overflow-hidden border-b border-th-bkg-2 sm:rounded-md`}
|
2021-04-07 14:49:37 -07:00
|
|
|
>
|
2021-04-20 07:19:08 -07:00
|
|
|
<Table className={`min-w-full divide-y divide-th-bkg-2`}>
|
|
|
|
<Thead>
|
|
|
|
<Tr>
|
|
|
|
<Th
|
2021-04-07 14:49:37 -07:00
|
|
|
scope="col"
|
2021-04-20 07:19:08 -07:00
|
|
|
className={`px-6 py-3 text-left font-normal`}
|
2021-04-07 14:49:37 -07:00
|
|
|
>
|
2021-04-12 21:40:26 -07:00
|
|
|
Market
|
2021-04-20 07:19:08 -07:00
|
|
|
</Th>
|
|
|
|
<Th
|
2021-04-07 14:49:37 -07:00
|
|
|
scope="col"
|
2021-04-20 07:19:08 -07:00
|
|
|
className={`px-6 py-3 text-left font-normal`}
|
2021-04-07 14:49:37 -07:00
|
|
|
>
|
2021-04-12 21:40:26 -07:00
|
|
|
Side
|
2021-04-20 07:19:08 -07:00
|
|
|
</Th>
|
|
|
|
<Th
|
2021-04-07 14:49:37 -07:00
|
|
|
scope="col"
|
2021-04-20 07:19:08 -07:00
|
|
|
className={`px-6 py-3 text-left font-normal`}
|
2021-04-07 14:49:37 -07:00
|
|
|
>
|
2021-04-12 21:40:26 -07:00
|
|
|
Size
|
2021-04-20 07:19:08 -07:00
|
|
|
</Th>
|
|
|
|
<Th
|
2021-04-07 14:49:37 -07:00
|
|
|
scope="col"
|
2021-04-20 07:19:08 -07:00
|
|
|
className={`px-6 py-3 text-left font-normal`}
|
2021-04-07 14:49:37 -07:00
|
|
|
>
|
2021-04-12 21:40:26 -07:00
|
|
|
Price
|
2021-04-20 07:19:08 -07:00
|
|
|
</Th>
|
|
|
|
<Th
|
2021-04-07 14:49:37 -07:00
|
|
|
scope="col"
|
2021-04-20 07:19:08 -07:00
|
|
|
className={`px-6 py-3 text-left font-normal`}
|
2021-04-07 14:49:37 -07:00
|
|
|
>
|
2021-04-12 21:40:26 -07:00
|
|
|
Liquidity
|
2021-04-20 07:19:08 -07:00
|
|
|
</Th>
|
|
|
|
<Th
|
2021-04-07 14:49:37 -07:00
|
|
|
scope="col"
|
2021-04-20 07:19:08 -07:00
|
|
|
className={`px-6 py-3 text-left font-normal`}
|
2021-04-07 14:49:37 -07:00
|
|
|
>
|
2021-04-12 21:40:26 -07:00
|
|
|
Fees
|
2021-04-20 07:19:08 -07:00
|
|
|
</Th>
|
|
|
|
<Th
|
2021-04-13 16:41:04 -07:00
|
|
|
scope="col"
|
2021-04-20 07:19:08 -07:00
|
|
|
className={`px-6 py-3 text-left font-normal`}
|
2021-04-13 16:41:04 -07:00
|
|
|
>
|
|
|
|
Date
|
2021-04-20 07:19:08 -07:00
|
|
|
</Th>
|
|
|
|
</Tr>
|
|
|
|
</Thead>
|
|
|
|
<Tbody>
|
2021-04-12 21:40:26 -07:00
|
|
|
{tradeHistory.map((trade, index) => (
|
2021-04-20 07:19:08 -07:00
|
|
|
<Tr
|
2021-04-14 23:16:36 -07:00
|
|
|
key={`${trade.orderId}${trade.side}${trade.uuid}`}
|
2021-04-20 07:19:08 -07:00
|
|
|
className={`border-b border-th-bkg-3
|
2021-04-13 16:41:04 -07:00
|
|
|
${index % 2 === 0 ? `bg-th-bkg-3` : `bg-th-bkg-2`}
|
2021-04-12 09:49:02 -07:00
|
|
|
`}
|
2021-04-07 14:49:37 -07:00
|
|
|
>
|
2021-04-20 07:19:08 -07:00
|
|
|
<Td
|
|
|
|
className={`px-6 py-4 whitespace-nowrap text-sm text-th-fgd-1`}
|
2021-04-07 14:49:37 -07:00
|
|
|
>
|
2021-04-12 21:40:26 -07:00
|
|
|
{trade.marketName}
|
2021-04-20 07:19:08 -07:00
|
|
|
</Td>
|
|
|
|
<Td
|
|
|
|
className={`px-6 py-4 whitespace-nowrap text-sm text-th-fgd-1`}
|
2021-04-07 14:49:37 -07:00
|
|
|
>
|
2021-04-20 07:19:08 -07:00
|
|
|
<SideBadge side={trade.side} />
|
|
|
|
</Td>
|
|
|
|
<Td
|
|
|
|
className={`px-6 py-4 whitespace-nowrap text-sm text-th-fgd-1`}
|
2021-04-07 14:49:37 -07:00
|
|
|
>
|
2021-04-12 21:40:26 -07:00
|
|
|
{trade.size}
|
2021-04-20 07:19:08 -07:00
|
|
|
</Td>
|
|
|
|
<Td
|
|
|
|
className={`px-6 py-4 whitespace-nowrap text-sm text-th-fgd-1`}
|
2021-04-07 14:49:37 -07:00
|
|
|
>
|
2021-04-12 21:40:26 -07:00
|
|
|
{trade.price}
|
2021-04-20 07:19:08 -07:00
|
|
|
</Td>
|
|
|
|
<Td
|
|
|
|
className={`px-6 py-4 whitespace-nowrap text-sm text-th-fgd-1`}
|
2021-04-07 14:49:37 -07:00
|
|
|
>
|
2021-04-12 21:40:26 -07:00
|
|
|
{trade.liquidity}
|
2021-04-20 07:19:08 -07:00
|
|
|
</Td>
|
|
|
|
<Td
|
|
|
|
className={`px-6 py-4 whitespace-nowrap text-sm text-th-fgd-1`}
|
2021-04-07 14:49:37 -07:00
|
|
|
>
|
2021-04-12 21:40:26 -07:00
|
|
|
{trade.feeCost}
|
2021-04-20 07:19:08 -07:00
|
|
|
</Td>
|
|
|
|
<Td
|
|
|
|
className={`px-6 py-4 whitespace-nowrap text-sm text-th-fgd-1`}
|
2021-04-13 16:41:04 -07:00
|
|
|
>
|
|
|
|
{trade.loadTimestamp
|
|
|
|
? new Date(trade.loadTimestamp).toLocaleDateString()
|
|
|
|
: 'Recent'}
|
2021-04-20 07:19:08 -07:00
|
|
|
</Td>
|
|
|
|
</Tr>
|
2021-04-07 14:49:37 -07:00
|
|
|
))}
|
2021-04-20 07:19:08 -07:00
|
|
|
</Tbody>
|
|
|
|
</Table>
|
2021-04-07 14:49:37 -07:00
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<div
|
2021-04-19 06:45:59 -07:00
|
|
|
className={`w-full text-center py-6 bg-th-bkg-1 text-th-fgd-3 rounded-md`}
|
2021-04-07 14:49:37 -07:00
|
|
|
>
|
2021-04-15 10:52:25 -07:00
|
|
|
No trade history
|
2021-04-07 14:49:37 -07:00
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default TradeHistoryTable
|