2021-04-02 11:26:21 -07:00
|
|
|
import dynamic from 'next/dynamic'
|
|
|
|
import { Responsive, WidthProvider } from 'react-grid-layout'
|
|
|
|
|
|
|
|
const TVChartContainer = dynamic(
|
|
|
|
() => import('../components/TradingView/index'),
|
|
|
|
{ ssr: false }
|
|
|
|
)
|
2021-04-17 17:04:18 -07:00
|
|
|
import { useEffect, useState } from 'react'
|
2021-04-02 11:26:21 -07:00
|
|
|
import FloatingElement from '../components/FloatingElement'
|
2021-06-17 14:07:10 -07:00
|
|
|
import Orderbook from '../components/Orderbook'
|
2021-06-20 11:08:14 -07:00
|
|
|
import MarginInfo from './MarginInfo'
|
2021-04-09 07:27:49 -07:00
|
|
|
import MarginBalances from './MarginBalances'
|
2021-06-17 15:37:03 -07:00
|
|
|
import TradeForm from './TradeForm'
|
2021-06-18 08:17:49 -07:00
|
|
|
import UserInfo from './UserInfo'
|
2021-06-16 18:50:16 -07:00
|
|
|
// import RecentMarketTrades from './RecentMarketTrades'
|
2021-04-13 09:51:42 -07:00
|
|
|
import useMangoStore from '../stores/useMangoStore'
|
2021-04-16 13:17:33 -07:00
|
|
|
import useLocalStorageState from '../hooks/useLocalStorageState'
|
2021-04-02 11:26:21 -07:00
|
|
|
|
|
|
|
const ResponsiveGridLayout = WidthProvider(Responsive)
|
|
|
|
|
2021-04-22 05:33:35 -07:00
|
|
|
export const defaultLayouts = {
|
2021-04-05 07:32:11 -07:00
|
|
|
xl: [
|
2021-05-01 21:31:55 -07:00
|
|
|
{ i: 'tvChart', x: 0, y: 0, w: 6, h: 30 },
|
|
|
|
{ i: 'orderbook', x: 6, y: 0, w: 3, h: 17 },
|
|
|
|
{ i: 'tradeForm', x: 9, y: 0, w: 3, h: 12 },
|
|
|
|
{ i: 'marketTrades', x: 6, y: 1, w: 3, h: 13 },
|
2021-06-05 09:14:34 -07:00
|
|
|
{ i: 'balanceInfo', x: 9, y: 1, w: 3, h: 15 },
|
2021-06-12 10:46:06 -07:00
|
|
|
{ i: 'userInfo', x: 0, y: 2, w: 9, h: 19 },
|
2021-05-01 21:31:55 -07:00
|
|
|
{ i: 'marginInfo', x: 9, y: 2, w: 3, h: 13 },
|
2021-04-05 07:32:11 -07:00
|
|
|
],
|
|
|
|
lg: [
|
User account page (#22)
* layout, overview, start on assets, borrows and open orders
* trade history, sortable data hook for tables, borrow page
* handle deposit and withdraw buttons
* borrow modal ui and integration + settle borrow for individual assets
* in orders balance to asset table and totals, responsive css, new connected wallet button + small tweaks
* account switch/creation flow
* accounts modal, update to usebalances hook
* handle settle, deposit before settle, save last account
* disable borrow/withdraw button when no account
2021-06-05 07:11:44 -07:00
|
|
|
{ i: 'tvChart', x: 0, y: 0, w: 8, h: 26, minW: 2 },
|
2021-06-05 09:14:34 -07:00
|
|
|
{ i: 'balanceInfo', x: 8, y: 0, w: 4, h: 15, minW: 2 },
|
2021-05-01 21:31:55 -07:00
|
|
|
{ i: 'marginInfo', x: 8, y: 1, w: 4, h: 13, minW: 2 },
|
|
|
|
{ i: 'orderbook', x: 0, y: 2, w: 4, h: 17, minW: 2 },
|
|
|
|
{ i: 'tradeForm', x: 4, y: 2, w: 4, h: 17, minW: 3 },
|
|
|
|
{ i: 'marketTrades', x: 8, y: 2, w: 4, h: 17, minW: 2 },
|
2021-06-12 10:46:06 -07:00
|
|
|
{ i: 'userInfo', x: 0, y: 3, w: 12, h: 19, minW: 6 },
|
2021-05-01 21:31:55 -07:00
|
|
|
],
|
|
|
|
md: [
|
User account page (#22)
* layout, overview, start on assets, borrows and open orders
* trade history, sortable data hook for tables, borrow page
* handle deposit and withdraw buttons
* borrow modal ui and integration + settle borrow for individual assets
* in orders balance to asset table and totals, responsive css, new connected wallet button + small tweaks
* account switch/creation flow
* accounts modal, update to usebalances hook
* handle settle, deposit before settle, save last account
* disable borrow/withdraw button when no account
2021-06-05 07:11:44 -07:00
|
|
|
{ i: 'tvChart', x: 0, y: 0, w: 8, h: 26, minW: 2 },
|
2021-06-05 09:14:34 -07:00
|
|
|
{ i: 'balanceInfo', x: 8, y: 0, w: 4, h: 15, minW: 2 },
|
2021-05-01 21:31:55 -07:00
|
|
|
{ i: 'marginInfo', x: 8, y: 1, w: 4, h: 13, minW: 2 },
|
|
|
|
{ i: 'orderbook', x: 0, y: 2, w: 4, h: 17, minW: 2 },
|
|
|
|
{ i: 'tradeForm', x: 4, y: 2, w: 4, h: 17, minW: 3 },
|
|
|
|
{ i: 'marketTrades', x: 8, y: 2, w: 4, h: 17, minW: 2 },
|
2021-06-12 10:46:06 -07:00
|
|
|
{ i: 'userInfo', x: 0, y: 3, w: 12, h: 19, minW: 6 },
|
2021-05-01 21:31:55 -07:00
|
|
|
],
|
|
|
|
sm: [
|
|
|
|
{ i: 'tvChart', x: 0, y: 0, w: 12, h: 25, minW: 6 },
|
2021-06-05 09:14:34 -07:00
|
|
|
{ i: 'balanceInfo', x: 0, y: 1, w: 6, h: 15, minW: 2 },
|
User account page (#22)
* layout, overview, start on assets, borrows and open orders
* trade history, sortable data hook for tables, borrow page
* handle deposit and withdraw buttons
* borrow modal ui and integration + settle borrow for individual assets
* in orders balance to asset table and totals, responsive css, new connected wallet button + small tweaks
* account switch/creation flow
* accounts modal, update to usebalances hook
* handle settle, deposit before settle, save last account
* disable borrow/withdraw button when no account
2021-06-05 07:11:44 -07:00
|
|
|
{ i: 'marginInfo', x: 6, y: 1, w: 6, h: 13, minW: 2 },
|
2021-05-01 21:31:55 -07:00
|
|
|
{ i: 'tradeForm', x: 0, y: 2, w: 12, h: 13, minW: 3 },
|
|
|
|
{ i: 'orderbook', x: 0, y: 3, w: 6, h: 17, minW: 3 },
|
|
|
|
{ i: 'marketTrades', x: 6, y: 3, w: 6, h: 17, minW: 2 },
|
2021-06-12 10:46:06 -07:00
|
|
|
{ i: 'userInfo', x: 0, y: 4, w: 12, h: 19, minW: 6 },
|
2021-05-01 21:31:55 -07:00
|
|
|
],
|
|
|
|
xs: [
|
|
|
|
{ i: 'tvChart', x: 0, y: 0, w: 0, h: 0, minW: 6 },
|
2021-06-05 09:14:34 -07:00
|
|
|
{ i: 'balanceInfo', x: 0, y: 1, w: 6, h: 15, minW: 2 },
|
2021-05-01 21:31:55 -07:00
|
|
|
{ i: 'marginInfo', x: 0, y: 2, w: 6, h: 13, minW: 2 },
|
|
|
|
{ i: 'tradeForm', x: 0, y: 3, w: 12, h: 13, minW: 3 },
|
|
|
|
{ i: 'orderbook', x: 0, y: 4, w: 6, h: 17, minW: 3 },
|
|
|
|
{ i: 'marketTrades', x: 0, y: 5, w: 6, h: 17, minW: 2 },
|
2021-06-12 10:46:06 -07:00
|
|
|
{ i: 'userInfo', x: 0, y: 6, w: 12, h: 19, minW: 6 },
|
2021-04-05 07:32:11 -07:00
|
|
|
],
|
|
|
|
}
|
|
|
|
|
2021-06-12 10:46:06 -07:00
|
|
|
export const GRID_LAYOUT_KEY = 'mangoSavedLayouts-2.2'
|
2021-05-01 21:31:55 -07:00
|
|
|
|
2021-04-02 11:26:21 -07:00
|
|
|
const TradePageGrid = () => {
|
2021-04-13 09:51:42 -07:00
|
|
|
const { uiLocked } = useMangoStore((s) => s.settings)
|
2021-04-16 13:17:33 -07:00
|
|
|
const [savedLayouts, setSavedLayouts] = useLocalStorageState(
|
2021-05-01 21:31:55 -07:00
|
|
|
GRID_LAYOUT_KEY,
|
2021-04-16 13:17:33 -07:00
|
|
|
defaultLayouts
|
|
|
|
)
|
|
|
|
|
2021-04-16 14:54:46 -07:00
|
|
|
const onLayoutChange = (layouts) => {
|
2021-04-16 14:40:20 -07:00
|
|
|
if (layouts) {
|
|
|
|
setSavedLayouts(layouts)
|
|
|
|
}
|
2021-04-16 13:17:33 -07:00
|
|
|
}
|
2021-04-13 09:51:42 -07:00
|
|
|
|
2021-04-17 17:04:18 -07:00
|
|
|
const [mounted, setMounted] = useState(false)
|
|
|
|
useEffect(() => setMounted(true), [])
|
|
|
|
if (!mounted) return null
|
|
|
|
|
2021-04-02 11:26:21 -07:00
|
|
|
return (
|
|
|
|
<ResponsiveGridLayout
|
|
|
|
className="layout"
|
2021-04-16 13:17:33 -07:00
|
|
|
layouts={savedLayouts || defaultLayouts}
|
2021-04-17 17:04:18 -07:00
|
|
|
breakpoints={{ xl: 1600, lg: 1200, md: 1110, sm: 768, xs: 0 }}
|
2021-05-01 21:31:55 -07:00
|
|
|
cols={{ xl: 12, lg: 12, md: 12, sm: 12, xs: 1 }}
|
2021-04-05 12:03:20 -07:00
|
|
|
rowHeight={15}
|
2021-04-13 09:51:42 -07:00
|
|
|
isDraggable={!uiLocked}
|
|
|
|
isResizable={!uiLocked}
|
2021-04-16 14:54:46 -07:00
|
|
|
onLayoutChange={(layout, layouts) => onLayoutChange(layouts)}
|
2021-04-02 11:26:21 -07:00
|
|
|
>
|
2021-04-05 12:03:20 -07:00
|
|
|
<div key="tvChart">
|
2021-04-24 15:23:01 -07:00
|
|
|
<FloatingElement className="pl-0">
|
2021-04-02 11:26:21 -07:00
|
|
|
<TVChartContainer />
|
|
|
|
</FloatingElement>
|
|
|
|
</div>
|
2021-06-18 15:38:09 -07:00
|
|
|
<div key="orderbook">
|
|
|
|
<Orderbook />
|
|
|
|
</div>
|
|
|
|
<div key="tradeForm">
|
|
|
|
<TradeForm />
|
|
|
|
</div>
|
2021-06-20 11:08:14 -07:00
|
|
|
<div key="marginInfo">
|
|
|
|
<MarginInfo />
|
|
|
|
</div>
|
2021-06-18 08:17:49 -07:00
|
|
|
<div key="userInfo">
|
|
|
|
<UserInfo />
|
|
|
|
</div>
|
2021-04-09 07:27:49 -07:00
|
|
|
<div key="balanceInfo">
|
|
|
|
<MarginBalances />
|
|
|
|
</div>
|
2021-06-16 18:50:16 -07:00
|
|
|
<div key="marketTrades">{/* <RecentMarketTrades /> */}</div>
|
2021-04-02 11:26:21 -07:00
|
|
|
</ResponsiveGridLayout>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default TradePageGrid
|