2021-10-01 03:05:42 -07:00
|
|
|
import { useEffect } from 'react'
|
|
|
|
import { useRouter } from 'next/router'
|
|
|
|
import { Responsive, WidthProvider } from 'react-grid-layout'
|
2021-03-30 15:47:08 -07:00
|
|
|
import TopBar from '../components/TopBar'
|
2021-04-06 15:11:42 -07:00
|
|
|
import MarketSelect from '../components/MarketSelect'
|
2021-04-15 09:34:59 -07:00
|
|
|
import useLocalStorageState from '../hooks/useLocalStorageState'
|
2021-09-19 17:36:02 -07:00
|
|
|
import { PageBodyWrapper } from '../components/styles'
|
2021-10-01 03:05:42 -07:00
|
|
|
import { DEFAULT_MARKET_KEY, initialMarket } from '../components/SettingsModal'
|
|
|
|
import {
|
|
|
|
breakpoints,
|
|
|
|
defaultLayouts,
|
|
|
|
GRID_LAYOUT_KEY,
|
|
|
|
} from '../components/TradePageGrid'
|
2021-10-20 05:42:40 -07:00
|
|
|
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
|
|
|
|
2021-11-14 10:37:02 -08:00
|
|
|
export async function getStaticProps({ locale }) {
|
2021-10-20 05:42:40 -07:00
|
|
|
return {
|
|
|
|
props: {
|
2021-10-25 14:03:00 -07:00
|
|
|
...(await serverSideTranslations(locale, ['common', 'tv-chart'])),
|
2021-10-20 05:42:40 -07:00
|
|
|
// Will be passed to the page component as props
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
2021-10-01 03:05:42 -07:00
|
|
|
|
|
|
|
const ResponsiveGridLayout = WidthProvider(Responsive)
|
2021-03-30 15:47:08 -07:00
|
|
|
|
|
|
|
const Index = () => {
|
2021-10-01 03:05:42 -07:00
|
|
|
const [defaultMarket] = useLocalStorageState(
|
|
|
|
DEFAULT_MARKET_KEY,
|
|
|
|
initialMarket
|
|
|
|
)
|
|
|
|
const [savedLayouts] = useLocalStorageState(GRID_LAYOUT_KEY, defaultLayouts)
|
|
|
|
const router = useRouter()
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const { pathname } = router
|
|
|
|
if (pathname == '/') {
|
|
|
|
router.push(defaultMarket.path)
|
|
|
|
}
|
|
|
|
}, [])
|
2021-04-06 15:11:42 -07:00
|
|
|
|
2021-03-30 15:47:08 -07:00
|
|
|
return (
|
2021-04-13 07:10:57 -07:00
|
|
|
<div className={`bg-th-bkg-1 text-th-fgd-1 transition-all `}>
|
2021-04-02 11:26:21 -07:00
|
|
|
<TopBar />
|
2021-04-11 14:25:01 -07:00
|
|
|
<MarketSelect />
|
2021-09-19 17:36:02 -07:00
|
|
|
<PageBodyWrapper className="p-1 sm:px-2 sm:py-1 md:px-2 md:py-1">
|
2021-10-01 03:05:42 -07:00
|
|
|
<div className="animate animate-pulse bg-th-bkg-3 rounded-lg h-10 md:mb-1 mt-6 mx-2 md:mx-3" />
|
|
|
|
<ResponsiveGridLayout
|
|
|
|
className="layout"
|
|
|
|
layouts={savedLayouts || defaultLayouts}
|
|
|
|
breakpoints={breakpoints}
|
|
|
|
cols={{ xl: 12, lg: 12, md: 12, sm: 12, xs: 1 }}
|
|
|
|
rowHeight={15}
|
|
|
|
isDraggable={false}
|
|
|
|
isResizable={false}
|
|
|
|
useCSSTransforms={false}
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
className="animate animate-pulse bg-th-bkg-3 rounded-lg"
|
|
|
|
key="tvChart"
|
|
|
|
></div>
|
|
|
|
<div
|
|
|
|
className="animate animate-pulse bg-th-bkg-3 rounded-lg"
|
|
|
|
key="orderbook"
|
|
|
|
></div>
|
|
|
|
<div
|
|
|
|
className="animate animate-pulse bg-th-bkg-3 rounded-lg"
|
|
|
|
key="tradeForm"
|
|
|
|
></div>
|
|
|
|
<div
|
|
|
|
className="animate animate-pulse bg-th-bkg-3 rounded-lg"
|
|
|
|
key="accountInfo"
|
|
|
|
></div>
|
|
|
|
<div
|
|
|
|
className="animate animate-pulse bg-th-bkg-3 rounded-lg"
|
|
|
|
key="userInfo"
|
|
|
|
></div>
|
|
|
|
<div
|
|
|
|
className="animate animate-pulse bg-th-bkg-3 rounded-lg"
|
|
|
|
key="marketPosition"
|
|
|
|
></div>
|
|
|
|
<div
|
|
|
|
className="animate animate-pulse bg-th-bkg-3 rounded-lg"
|
|
|
|
key="marketTrades"
|
|
|
|
></div>
|
|
|
|
</ResponsiveGridLayout>
|
2021-09-19 17:36:02 -07:00
|
|
|
</PageBodyWrapper>
|
2021-03-30 15:47:08 -07:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
2021-03-26 09:44:55 -07:00
|
|
|
|
2021-03-30 15:47:08 -07:00
|
|
|
export default Index
|