2022-03-30 09:49:48 +00:00
|
|
|
import type { AppProps } from 'next/app';
|
2022-09-02 14:53:38 +00:00
|
|
|
import Head from 'next/head';
|
2022-02-17 05:08:17 +00:00
|
|
|
import { Navbar } from '../components/navbar';
|
2022-03-31 17:16:30 +00:00
|
|
|
import { t, ThemeContext, useThemeSwitcher } from '@vegaprotocol/react-helpers';
|
2022-09-05 14:25:33 +00:00
|
|
|
import { VegaConnectDialog, VegaWalletProvider } from '@vegaprotocol/wallet';
|
2022-08-04 09:14:49 +00:00
|
|
|
import { EnvironmentProvider } from '@vegaprotocol/environment';
|
2022-03-25 07:44:10 +00:00
|
|
|
import { Connectors } from '../lib/vega-connectors';
|
2022-03-11 00:28:48 +00:00
|
|
|
import { AppLoader } from '../components/app-loader';
|
2022-09-02 14:53:38 +00:00
|
|
|
import { RiskNoticeDialog } from '../components/risk-notice-dialog';
|
2022-03-14 13:18:11 +00:00
|
|
|
import './styles.css';
|
2022-06-01 14:21:36 +00:00
|
|
|
import { useGlobalStore } from '../stores';
|
2022-08-17 14:10:01 +00:00
|
|
|
import {
|
|
|
|
AssetDetailsDialog,
|
|
|
|
useAssetDetailsDialogStore,
|
2022-08-26 15:39:40 +00:00
|
|
|
} from '@vegaprotocol/assets';
|
2022-08-31 04:35:46 +00:00
|
|
|
import { Footer } from '../components/footer';
|
2022-03-14 13:18:11 +00:00
|
|
|
|
2022-06-10 09:15:38 +00:00
|
|
|
function AppBody({ Component, pageProps }: AppProps) {
|
2022-09-05 14:25:33 +00:00
|
|
|
const { connectDialog, update } = useGlobalStore((store) => ({
|
|
|
|
connectDialog: store.connectDialog,
|
|
|
|
update: store.update,
|
|
|
|
}));
|
2022-08-17 14:10:01 +00:00
|
|
|
const {
|
|
|
|
isAssetDetailsDialogOpen,
|
|
|
|
assetDetailsDialogSymbol,
|
|
|
|
setAssetDetailsDialogOpen,
|
|
|
|
} = useAssetDetailsDialogStore();
|
2022-06-24 03:16:01 +00:00
|
|
|
const [theme, toggleTheme] = useThemeSwitcher();
|
2022-06-10 09:15:38 +00:00
|
|
|
|
|
|
|
return (
|
2022-06-24 03:16:01 +00:00
|
|
|
<ThemeContext.Provider value={theme}>
|
2022-08-31 04:35:46 +00:00
|
|
|
<Head>
|
|
|
|
<title>{t('Welcome to Vega trading!')}</title>
|
|
|
|
</Head>
|
|
|
|
<div className="h-full relative dark:bg-black dark:text-white z-0 grid grid-rows-[min-content,1fr,min-content]">
|
2022-06-24 03:16:01 +00:00
|
|
|
<AppLoader>
|
2022-08-31 04:35:46 +00:00
|
|
|
<Navbar theme={theme} toggleTheme={toggleTheme} />
|
|
|
|
<main data-testid={pageProps.page}>
|
2022-06-24 03:16:01 +00:00
|
|
|
{/* @ts-ignore conflict between @types/react and nextjs internal types */}
|
|
|
|
<Component {...pageProps} />
|
|
|
|
</main>
|
2022-08-31 04:35:46 +00:00
|
|
|
<Footer />
|
2022-06-24 03:16:01 +00:00
|
|
|
<VegaConnectDialog
|
|
|
|
connectors={Connectors}
|
2022-09-05 14:25:33 +00:00
|
|
|
dialogOpen={connectDialog}
|
|
|
|
setDialogOpen={(open) => update({ connectDialog: open })}
|
2022-06-24 03:16:01 +00:00
|
|
|
/>
|
2022-08-17 14:10:01 +00:00
|
|
|
<AssetDetailsDialog
|
|
|
|
assetSymbol={assetDetailsDialogSymbol}
|
|
|
|
open={isAssetDetailsDialogOpen}
|
|
|
|
onChange={(open) => setAssetDetailsDialogOpen(open)}
|
|
|
|
/>
|
2022-09-02 14:53:38 +00:00
|
|
|
<RiskNoticeDialog />
|
2022-06-24 03:16:01 +00:00
|
|
|
</AppLoader>
|
|
|
|
</div>
|
|
|
|
</ThemeContext.Provider>
|
2022-06-10 09:15:38 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function VegaTradingApp(props: AppProps) {
|
2022-02-11 13:56:28 +00:00
|
|
|
return (
|
2022-06-01 00:30:02 +00:00
|
|
|
<EnvironmentProvider>
|
2022-06-24 03:16:01 +00:00
|
|
|
<VegaWalletProvider>
|
|
|
|
<AppBody {...props} />
|
|
|
|
</VegaWalletProvider>
|
2022-06-01 00:30:02 +00:00
|
|
|
</EnvironmentProvider>
|
2022-02-11 13:56:28 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-02-17 05:03:46 +00:00
|
|
|
export default VegaTradingApp;
|