-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
Copy pathindex.tsx
46 lines (42 loc) · 1.27 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { useTranslation } from '@pancakeswap/localization'
import { SubMenuItems } from '@pancakeswap/uikit'
import { useRouter } from 'next/router'
import { useMemo } from 'react'
import { multiChainQueryStableClient } from 'state/info/constant'
import { useChainNameByQuery, useMultiChainPath } from 'state/info/hooks'
import InfoNav from './components/InfoNav'
export const InfoPageLayout = ({ children }) => {
const router = useRouter()
const chainName = useChainNameByQuery()
const chainPath = useMultiChainPath()
const { t } = useTranslation()
const isStableSwap = router.query.type === 'stableSwap'
const subMenuItems = useMemo(() => {
const config = [
{
label: t('V3'),
href: `/info/v3${chainPath}`,
},
{
label: t('V2'),
href: `/info${chainPath}`,
},
]
if (multiChainQueryStableClient[chainName])
config.push({
label: t('StableSwap'),
href: `/info${chainPath}?type=stableSwap`,
})
return config
}, [t, chainPath, chainName])
return (
<>
<SubMenuItems
items={subMenuItems}
activeItem={isStableSwap ? `/info${chainPath}?type=stableSwap` : `/info${chainPath}`}
/>
<InfoNav isStableSwap={isStableSwap} />
{children}
</>
)
}