2019-05-30 23:42:25 +03:00
|
|
|
import React, { Suspense, lazy } from 'react'
|
|
|
|
import styled from 'styled-components'
|
2019-04-15 19:56:40 +03:00
|
|
|
import { BrowserRouter, Redirect, Route, Switch } from 'react-router-dom'
|
2019-04-25 19:12:47 +03:00
|
|
|
|
2019-05-30 23:42:25 +03:00
|
|
|
import Web3ReactManager from '../components/Web3ReactManager'
|
2019-04-15 19:56:40 +03:00
|
|
|
import Header from '../components/Header'
|
2019-08-07 21:58:29 +03:00
|
|
|
import Footer from '../components/Footer'
|
|
|
|
|
2019-05-30 23:42:25 +03:00
|
|
|
import NavigationTabs from '../components/NavigationTabs'
|
2019-06-14 17:39:33 +03:00
|
|
|
import { isAddress } from '../utils'
|
2018-10-07 00:24:17 +03:00
|
|
|
|
2019-05-30 23:42:25 +03:00
|
|
|
const Swap = lazy(() => import('./Swap'))
|
|
|
|
const Send = lazy(() => import('./Send'))
|
|
|
|
const Pool = lazy(() => import('./Pool'))
|
2018-10-27 10:54:52 +03:00
|
|
|
|
2019-08-07 21:58:29 +03:00
|
|
|
const AppWrapper = styled.div`
|
|
|
|
display: flex;
|
|
|
|
flex-flow: column;
|
|
|
|
align-items: flex-start;
|
|
|
|
height: 100vh;
|
|
|
|
`
|
|
|
|
|
2019-05-30 23:42:25 +03:00
|
|
|
const HeaderWrapper = styled.div`
|
|
|
|
${({ theme }) => theme.flexRowNoWrap}
|
|
|
|
width: 100%;
|
|
|
|
justify-content: space-between;
|
|
|
|
`
|
2019-08-07 21:58:29 +03:00
|
|
|
const FooterWrapper = styled.div`
|
|
|
|
width: 100%;
|
|
|
|
min-height: 30px;
|
|
|
|
align-self: flex-end;
|
|
|
|
`
|
2018-10-27 10:54:52 +03:00
|
|
|
|
2019-05-30 23:42:25 +03:00
|
|
|
const BodyWrapper = styled.div`
|
2019-08-07 21:58:29 +03:00
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
2019-05-30 23:42:25 +03:00
|
|
|
width: 100%;
|
2019-08-07 21:58:29 +03:00
|
|
|
justify-content: flex-start;
|
|
|
|
align-items: center;
|
|
|
|
flex: 1;
|
2019-05-30 23:42:25 +03:00
|
|
|
overflow: auto;
|
|
|
|
`
|
2019-04-25 19:12:47 +03:00
|
|
|
|
2019-05-30 23:42:25 +03:00
|
|
|
const Body = styled.div`
|
2019-08-07 21:58:29 +03:00
|
|
|
max-width: 35rem;
|
|
|
|
width: 90%;
|
|
|
|
/* margin: 0 1.25rem 1.25rem 1.25rem; */
|
2019-05-30 23:42:25 +03:00
|
|
|
`
|
2019-04-25 19:12:47 +03:00
|
|
|
|
2019-05-30 23:42:25 +03:00
|
|
|
export default function App() {
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Suspense fallback={null}>
|
2019-08-07 21:58:29 +03:00
|
|
|
<AppWrapper>
|
|
|
|
<HeaderWrapper>
|
|
|
|
<Header />
|
|
|
|
</HeaderWrapper>
|
|
|
|
<BodyWrapper>
|
|
|
|
<Body>
|
|
|
|
<Web3ReactManager>
|
|
|
|
<BrowserRouter>
|
|
|
|
<NavigationTabs />
|
|
|
|
{/* this Suspense is for route code-splitting */}
|
|
|
|
<Suspense fallback={null}>
|
|
|
|
<Switch>
|
|
|
|
<Route exact strict path="/swap" component={Swap} />
|
|
|
|
<Route
|
|
|
|
exact
|
|
|
|
strict
|
|
|
|
path="/swap/:tokenAddress?"
|
|
|
|
render={({ match }) => {
|
|
|
|
if (isAddress(match.params.tokenAddress)) {
|
|
|
|
return <Swap initialCurrency={isAddress(match.params.tokenAddress)} />
|
|
|
|
} else {
|
|
|
|
return <Redirect to={{ pathname: '/swap' }} />
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<Route exact strict path="/send" component={Send} />
|
|
|
|
<Route
|
|
|
|
exact
|
|
|
|
strict
|
|
|
|
path="/send/:tokenAddress?"
|
|
|
|
render={({ match }) => {
|
|
|
|
if (isAddress(match.params.tokenAddress)) {
|
|
|
|
return <Send initialCurrency={isAddress(match.params.tokenAddress)} />
|
|
|
|
} else {
|
|
|
|
return <Redirect to={{ pathname: '/send' }} />
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<Route
|
|
|
|
path={[
|
|
|
|
'/add-liquidity',
|
|
|
|
'/remove-liquidity',
|
|
|
|
'/create-exchange',
|
|
|
|
'/create-exchange/:tokenAddress?'
|
|
|
|
]}
|
|
|
|
component={Pool}
|
|
|
|
/>
|
|
|
|
<Redirect to="/swap" />
|
|
|
|
</Switch>
|
|
|
|
</Suspense>
|
|
|
|
</BrowserRouter>
|
|
|
|
</Web3ReactManager>
|
|
|
|
</Body>
|
|
|
|
</BodyWrapper>
|
|
|
|
<FooterWrapper>
|
|
|
|
<Footer />
|
|
|
|
</FooterWrapper>
|
|
|
|
</AppWrapper>
|
2019-05-30 23:42:25 +03:00
|
|
|
</Suspense>
|
|
|
|
</>
|
|
|
|
)
|
2018-10-07 00:24:17 +03:00
|
|
|
}
|