mango-ui-v3/pages/_app.tsx

137 lines
4.6 KiB
TypeScript
Raw Normal View History

import Head from 'next/head'
2021-04-11 14:25:01 -07:00
import { ThemeProvider } from 'next-themes'
2021-04-02 11:26:21 -07:00
import '../node_modules/react-grid-layout/css/styles.css'
import '../node_modules/react-resizable/css/styles.css'
2021-10-29 05:05:55 -07:00
import 'intro.js/introjs.css'
2021-04-02 11:26:21 -07:00
import '../styles/index.css'
import useWallet from '../hooks/useWallet'
import useHydrateStore from '../hooks/useHydrateStore'
2021-04-24 19:10:28 -07:00
import Notifications from '../components/Notification'
import useMangoStore from '../stores/useMangoStore'
import useOraclePrice from '../hooks/useOraclePrice'
import { getDecimalCount } from '../utils'
import { useRouter } from 'next/router'
2021-09-03 05:11:21 -07:00
import { ViewportProvider } from '../hooks/useViewport'
import BottomBar from '../components/mobile/BottomBar'
import { appWithTranslation } from 'next-i18next'
2021-12-28 14:22:50 -08:00
import ErrorBoundary from '../components/ErrorBoundary'
2022-01-07 14:52:16 -08:00
import GlobalNotification from '../components/GlobalNotification'
2022-01-27 08:57:36 -08:00
import { useOpenOrders } from '../hooks/useOpenOrders'
2022-01-27 19:57:18 -08:00
import usePerpPositions from '../hooks/usePerpPositions'
2021-12-05 17:13:23 -08:00
const MangoStoreUpdater = () => {
useHydrateStore()
2022-01-27 19:57:18 -08:00
return null
}
const WalletStoreUpdater = () => {
useWallet()
2022-01-27 19:57:18 -08:00
return null
}
const OpenOrdersStoreUpdater = () => {
2022-01-27 08:57:36 -08:00
useOpenOrders()
2022-01-27 19:57:18 -08:00
return null
}
2021-12-05 17:13:23 -08:00
2022-01-27 19:57:18 -08:00
const PerpPositionsStoreUpdater = () => {
usePerpPositions()
2021-12-05 17:13:23 -08:00
return null
}
const PageTitle = () => {
const router = useRouter()
const marketConfig = useMangoStore((s) => s.selectedMarket.config)
const market = useMangoStore((s) => s.selectedMarket.current)
const oraclePrice = useOraclePrice()
const selectedMarketName = marketConfig.name
const marketTitleString =
marketConfig && router.pathname.includes('market')
? `${
oraclePrice
? oraclePrice.toFixed(getDecimalCount(market?.tickSize)) + ' | '
: ''
}${selectedMarketName} - `
: ''
return (
<Head>
<title>{marketTitleString}Mango Markets</title>
</Head>
)
}
function App({ Component, pageProps }) {
return (
<>
<Head>
<title>Mango Markets</title>
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link
2022-01-31 07:52:28 -08:00
href="https://fonts.googleapis.com/css2?family=Lato:wght@200;300;400;500;600;700&display=swap"
rel="stylesheet"
/>
2021-04-13 13:34:06 -07:00
<link rel="icon" href="/favicon.ico" />
2021-10-11 14:46:52 -07:00
<meta property="og:title" content="Mango Markets" />
2021-04-13 13:34:06 -07:00
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta
name="keywords"
content="Mango Markets, Serum, SRM, Serum DEX, DEFI, Decentralized Finance, Decentralised Finance, Crypto, ERC20, Ethereum, Decentralize, Solana, SOL, SPL, Cross-Chain, Trading, Fastest, Fast, SerumBTC, SerumUSD, SRM Tokens, SPL Tokens"
/>
<meta
name="description"
2021-08-29 21:56:27 -07:00
content="Mango Markets - Decentralised, cross-margin trading up to 10x leverage with lightning speed and near-zero fees."
2021-04-13 13:34:06 -07:00
/>
<link
rel="apple-touch-icon"
sizes="192x192"
href="/apple-touch-icon.png"
/>
2021-04-13 13:34:06 -07:00
<meta name="msapplication-TileColor" content="#da532c" />
<meta name="theme-color" content="#ffffff" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="Mango Markets" />
<meta
name="twitter:description"
2021-08-29 21:56:27 -07:00
content="Mango Markets - Decentralised, cross-margin trading up to 10x leverage with lightning speed and near-zero fees."
2021-04-13 13:34:06 -07:00
/>
<meta name="twitter:image" content="/twitter-image.png" />
<meta name="google" content="notranslate" />
<script src="/datafeeds/udf/dist/polyfills.js"></script>
<script src="/datafeeds/udf/dist/bundle.js"></script>
2021-04-13 13:45:07 -07:00
<link rel="manifest" href="/manifest.json"></link>
</Head>
2021-12-28 14:22:50 -08:00
<ErrorBoundary>
<ErrorBoundary>
<PageTitle />
<MangoStoreUpdater />
2022-01-27 19:57:18 -08:00
<WalletStoreUpdater />
<OpenOrdersStoreUpdater />
<PerpPositionsStoreUpdater />
2021-12-28 14:22:50 -08:00
</ErrorBoundary>
<ThemeProvider defaultTheme="Mango">
<ViewportProvider>
<div className="bg-th-bkg-1 min-h-screen">
<ErrorBoundary>
2022-01-07 14:52:16 -08:00
<GlobalNotification />
2021-12-28 14:22:50 -08:00
<Component {...pageProps} />
</ErrorBoundary>
</div>
<div className="md:hidden fixed bottom-0 left-0 w-full z-20">
<ErrorBoundary>
<BottomBar />
</ErrorBoundary>
</div>
<Notifications />
</ViewportProvider>
</ThemeProvider>
</ErrorBoundary>
</>
)
}
export default appWithTranslation(App)