1
- import React , { useEffect } from 'react'
1
+ import React , { useEffect , useRef } from 'react'
2
2
import { Outlet , useLocation , useParams } from 'react-router-dom'
3
3
import { SnackbarProvider } from 'notistack'
4
4
import { initShibbolethPinger } from 'unfuck-spa-shibboleth-session'
@@ -7,6 +7,7 @@ import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'
7
7
import { fi } from 'date-fns/locale'
8
8
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFnsV3'
9
9
import { Box , Button , CssBaseline , Snackbar } from '@mui/material'
10
+ import { AppContext } from './util/context'
10
11
11
12
import { PUBLIC_URL } from '../config'
12
13
import { User } from './types'
@@ -71,6 +72,7 @@ const App = () => {
71
72
const theme = useTheme ( )
72
73
const { courseId } = useParams ( )
73
74
const location = useLocation ( )
75
+ const appRef = useRef < HTMLDivElement > ( null )
74
76
75
77
const { user, isLoading } = useCurrentUser ( )
76
78
@@ -94,14 +96,25 @@ const App = () => {
94
96
< CssBaseline />
95
97
< LocalizationProvider dateAdapter = { AdapterDateFns } adapterLocale = { fi } >
96
98
< SnackbarProvider preventDuplicate >
97
- < Box minHeight = "100vh" height = "100vh" display = "flex" flexDirection = "column" >
98
- < NavBar />
99
- < Box sx = { { flex : 1 } } >
100
- < Outlet />
99
+ < AppContext . Provider value = { appRef } >
100
+ < Box
101
+ sx = { {
102
+ display : 'flex' ,
103
+ flexDirection : 'column' ,
104
+ minHeight : '100vh' ,
105
+ height : '100vh' ,
106
+ overflowY : 'auto' ,
107
+ } }
108
+ ref = { appRef }
109
+ >
110
+ < NavBar />
111
+ < Box sx = { { flex : 1 } } >
112
+ < Outlet />
113
+ </ Box >
114
+ < Footer />
101
115
</ Box >
102
- < Footer />
103
- </ Box >
104
- < AdminLoggedInAsBanner />
116
+ < AdminLoggedInAsBanner />
117
+ </ AppContext . Provider >
105
118
</ SnackbarProvider >
106
119
</ LocalizationProvider >
107
120
</ ThemeProvider >
0 commit comments