forked from devias-io/material-kit-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_app.js
55 lines (47 loc) · 1.63 KB
/
_app.js
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
import Head from 'next/head';
import { CacheProvider } from '@emotion/react';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
import { CssBaseline } from '@mui/material';
import { ThemeProvider } from '@mui/material/styles';
import { AuthConsumer, AuthProvider } from 'src/contexts/auth-context';
import { useNProgress } from 'src/hooks/use-nprogress';
import { createTheme } from 'src/theme';
import { createEmotionCache } from 'src/utils/create-emotion-cache';
import 'simplebar-react/dist/simplebar.min.css';
const clientSideEmotionCache = createEmotionCache();
const SplashScreen = () => null;
const App = (props) => {
const { Component, emotionCache = clientSideEmotionCache, pageProps } = props;
useNProgress();
const getLayout = Component.getLayout ?? ((page) => page);
const theme = createTheme();
return (
<CacheProvider value={emotionCache}>
<Head>
<title>
Devias Kit
</title>
<meta
name="viewport"
content="initial-scale=1, width=device-width"
/>
</Head>
<LocalizationProvider dateAdapter={AdapterDateFns}>
<AuthProvider>
<ThemeProvider theme={theme}>
<CssBaseline />
<AuthConsumer>
{
(auth) => auth.isLoading
? <SplashScreen />
: getLayout(<Component {...pageProps} />)
}
</AuthConsumer>
</ThemeProvider>
</AuthProvider>
</LocalizationProvider>
</CacheProvider>
);
};
export default App;