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 }
|
|
|
|
)
|
|
|
|
import FloatingElement from '../components/FloatingElement'
|
|
|
|
import Orderbook from '../components/Orderbook'
|
2021-04-14 23:16:36 -07:00
|
|
|
import MarginInfo from './MarginInfo'
|
2021-04-09 07:27:49 -07:00
|
|
|
import MarginBalances from './MarginBalances'
|
2021-04-02 11:26:21 -07:00
|
|
|
import TradeForm from './TradeForm'
|
2021-04-05 07:32:11 -07:00
|
|
|
import UserInfo from './UserInfo'
|
2021-04-05 13:48:24 -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-16 13:17:33 -07:00
|
|
|
const defaultLayouts = {
|
2021-04-05 07:32:11 -07:00
|
|
|
xl: [
|
2021-04-05 12:03:20 -07:00
|
|
|
{ i: 'tvChart', x: 0, y: 0, w: 3, h: 30 },
|
|
|
|
{ i: 'orderbook', x: 3, y: 0, w: 1, h: 17 },
|
|
|
|
{ i: 'tradeForm', x: 4, y: 0, w: 1, h: 17 },
|
2021-04-14 23:16:36 -07:00
|
|
|
{ i: 'marginInfo', x: 4, y: 2, w: 1, h: 12 },
|
2021-04-05 14:38:59 -07:00
|
|
|
{ i: 'marketTrades', x: 3, y: 1, w: 1, h: 13 },
|
2021-04-16 04:50:56 -07:00
|
|
|
{ i: 'userInfo', x: 0, y: 2, w: 3, h: 17 },
|
2021-04-09 07:27:49 -07:00
|
|
|
{ i: 'balanceInfo', x: 4, y: 1, w: 1, h: 13 },
|
2021-04-05 07:32:11 -07:00
|
|
|
],
|
|
|
|
lg: [
|
2021-04-07 16:06:02 -07:00
|
|
|
{ i: 'tvChart', x: 0, y: 0, w: 2, h: 24 },
|
2021-04-12 13:01:55 -07:00
|
|
|
{ i: 'balanceInfo', x: 2, y: 0, w: 1, h: 13 },
|
2021-04-14 23:16:36 -07:00
|
|
|
{ i: 'marginInfo', x: 2, y: 1, w: 1, h: 11 },
|
2021-04-05 14:38:59 -07:00
|
|
|
{ i: 'orderbook', x: 0, y: 2, w: 1, h: 17 },
|
|
|
|
{ i: 'tradeForm', x: 1, y: 2, w: 1, h: 17 },
|
|
|
|
{ i: 'marketTrades', x: 2, y: 2, w: 1, h: 17 },
|
2021-04-07 16:06:02 -07:00
|
|
|
{ i: 'userInfo', x: 0, y: 3, w: 3, h: 17 },
|
2021-04-05 07:32:11 -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(
|
|
|
|
'savedLayouts',
|
|
|
|
defaultLayouts
|
|
|
|
)
|
|
|
|
|
|
|
|
const onLayoutChange = (layout, layouts) => {
|
|
|
|
setSavedLayouts(layouts)
|
|
|
|
}
|
2021-04-13 09:51:42 -07:00
|
|
|
|
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-05 07:32:11 -07:00
|
|
|
breakpoints={{ xl: 1600, lg: 1200, md: 996, sm: 768, xs: 0 }}
|
2021-04-05 14:38:59 -07:00
|
|
|
cols={{ xl: 5, lg: 3, md: 3, sm: 2, 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 13:17:33 -07:00
|
|
|
onLayoutChange={(layout, layouts) => onLayoutChange(layout, layouts)}
|
2021-04-02 11:26:21 -07:00
|
|
|
>
|
2021-04-05 12:03:20 -07:00
|
|
|
<div key="tvChart">
|
2021-04-02 11:26:21 -07:00
|
|
|
<FloatingElement>
|
|
|
|
<TVChartContainer />
|
|
|
|
</FloatingElement>
|
|
|
|
</div>
|
2021-04-05 12:03:20 -07:00
|
|
|
<div key="orderbook">
|
2021-04-02 11:26:21 -07:00
|
|
|
<FloatingElement>
|
|
|
|
<Orderbook />
|
|
|
|
</FloatingElement>
|
|
|
|
</div>
|
2021-04-05 12:03:20 -07:00
|
|
|
<div key="tradeForm">
|
2021-04-02 11:26:21 -07:00
|
|
|
<TradeForm />
|
|
|
|
</div>
|
2021-04-14 23:16:36 -07:00
|
|
|
<div key="marginInfo">
|
|
|
|
<MarginInfo />
|
2021-04-05 07:32:11 -07:00
|
|
|
</div>
|
2021-04-05 13:48:24 -07:00
|
|
|
<div key="userInfo">
|
2021-04-05 07:32:11 -07:00
|
|
|
<UserInfo />
|
|
|
|
</div>
|
2021-04-09 07:27:49 -07:00
|
|
|
<div key="balanceInfo">
|
|
|
|
<MarginBalances />
|
|
|
|
</div>
|
2021-04-05 13:48:24 -07:00
|
|
|
<div key="marketTrades">
|
|
|
|
<RecentMarketTrades />
|
|
|
|
</div>
|
2021-04-02 11:26:21 -07:00
|
|
|
</ResponsiveGridLayout>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default TradePageGrid
|