forked from pancakeswap/pancake-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
157 lines (149 loc) · 6.09 KB
/
App.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import React, { lazy } from 'react'
import { Router, Redirect, Route, Switch } from 'react-router-dom'
import { ResetCSS } from '@pancakeswap/uikit'
import BigNumber from 'bignumber.js'
import useEagerConnect from 'hooks/useEagerConnect'
import { usePollBlockNumber } from 'state/block/hooks'
import { usePollCoreFarmData } from 'state/farms/hooks'
import { useFetchProfile } from 'state/profile/hooks'
import { DatePickerPortal } from 'components/DatePicker'
import GlobalStyle from './style/Global'
import Menu from './components/Menu'
import SuspenseWithChunkError from './components/SuspenseWithChunkError'
import { ToastListener } from './contexts/ToastsContext'
import PageLoader from './components/Loader/PageLoader'
import EasterEgg from './components/EasterEgg'
import history from './routerHistory'
// Views included in the main bundle
import Pools from './views/Pools'
import Swap from './views/Swap'
import {
RedirectDuplicateTokenIds,
RedirectOldAddLiquidityPathStructure,
RedirectToAddLiquidity,
} from './views/AddLiquidity/redirects'
import RedirectOldRemoveLiquidityPathStructure from './views/RemoveLiquidity/redirects'
import { RedirectPathToSwapOnly, RedirectToSwap } from './views/Swap/redirects'
// Route-based code splitting
// Only pool is included in the main bundle because of it's the most visited page
const Home = lazy(() => import('./views/Home'))
const Farms = lazy(() => import('./views/Farms'))
const FarmAuction = lazy(() => import('./views/FarmAuction'))
const Lottery = lazy(() => import('./views/Lottery'))
const Ifos = lazy(() => import('./views/Ifos'))
const NotFound = lazy(() => import('./views/NotFound'))
const Collectibles = lazy(() => import('./views/Collectibles'))
const Teams = lazy(() => import('./views/Teams'))
const Team = lazy(() => import('./views/Teams/Team'))
const Profile = lazy(() => import('./views/Profile'))
const TradingCompetition = lazy(() => import('./views/TradingCompetition'))
const Predictions = lazy(() => import('./views/Predictions'))
const Voting = lazy(() => import('./views/Voting'))
const Proposal = lazy(() => import('./views/Voting/Proposal'))
const CreateProposal = lazy(() => import('./views/Voting/CreateProposal'))
const AddLiquidity = lazy(() => import('./views/AddLiquidity'))
const Liquidity = lazy(() => import('./views/Pool'))
const PoolFinder = lazy(() => import('./views/PoolFinder'))
const RemoveLiquidity = lazy(() => import('./views/RemoveLiquidity'))
// This config is required for number formatting
BigNumber.config({
EXPONENTIAL_AT: 1000,
DECIMAL_PLACES: 80,
})
const App: React.FC = () => {
usePollBlockNumber()
useEagerConnect()
useFetchProfile()
usePollCoreFarmData()
return (
<Router history={history}>
<ResetCSS />
<GlobalStyle />
<Menu>
<SuspenseWithChunkError fallback={<PageLoader />}>
<Switch>
<Route path="/" exact>
<Home />
</Route>
<Route exact path="/farms/auction">
<FarmAuction />
</Route>
<Route path="/farms">
<Farms />
</Route>
<Route path="/pools">
<Pools />
</Route>
<Route path="/lottery">
<Lottery />
</Route>
<Route path="/ifo">
<Ifos />
</Route>
<Route path="/collectibles">
<Collectibles />
</Route>
<Route exact path="/teams">
<Teams />
</Route>
<Route path="/teams/:id">
<Team />
</Route>
<Route path="/profile">
<Profile />
</Route>
<Route path="/competition">
<TradingCompetition />
</Route>
<Route path="/prediction">
<Predictions />
</Route>
<Route exact path="/voting">
<Voting />
</Route>
<Route exact path="/voting/proposal/create">
<CreateProposal />
</Route>
<Route path="/voting/proposal/:id">
<Proposal />
</Route>
{/* Using this format because these components use routes injected props. We need to rework them with hooks */}
<Route exact strict path="/swap" component={Swap} />
<Route exact strict path="/swap/:outputCurrency" component={RedirectToSwap} />
<Route exact strict path="/send" component={RedirectPathToSwapOnly} />
<Route exact strict path="/find" component={PoolFinder} />
<Route exact strict path="/liquidity" component={Liquidity} />
<Route exact strict path="/create" component={RedirectToAddLiquidity} />
<Route exact path="/add" component={AddLiquidity} />
<Route exact path="/add/:currencyIdA" component={RedirectOldAddLiquidityPathStructure} />
<Route exact path="/add/:currencyIdA/:currencyIdB" component={RedirectDuplicateTokenIds} />
<Route exact path="/create" component={AddLiquidity} />
<Route exact path="/create/:currencyIdA" component={RedirectOldAddLiquidityPathStructure} />
<Route exact path="/create/:currencyIdA/:currencyIdB" component={RedirectDuplicateTokenIds} />
<Route exact strict path="/remove/:tokens" component={RedirectOldRemoveLiquidityPathStructure} />
<Route exact strict path="/remove/:currencyIdA/:currencyIdB" component={RemoveLiquidity} />
{/* Redirect */}
<Route path="/pool">
<Redirect to="/liquidity" />
</Route>
<Route path="/staking">
<Redirect to="/pools" />
</Route>
<Route path="/syrup">
<Redirect to="/pools" />
</Route>
<Route path="/nft">
<Redirect to="/collectibles" />
</Route>
{/* 404 */}
<Route component={NotFound} />
</Switch>
</SuspenseWithChunkError>
</Menu>
<EasterEgg iterations={2} />
<ToastListener />
<DatePickerPortal />
</Router>
)
}
export default React.memo(App)