@@ -8,10 +8,9 @@ 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
10
import { AppContext } from './util/AppContext'
11
- import { ErrorBoundary } from './components/ErrorBoundary'
12
11
13
- import { PUBLIC_URL , inCI , inDevelopment , inProduction , inStaging } from '../config'
14
- import { User } from './types'
12
+ import { PUBLIC_URL } from '../config'
13
+ import type { User } from './types'
15
14
import useTheme from './theme'
16
15
import NavBar from './components/NavBar'
17
16
import Footer from './components/Footer'
@@ -78,62 +77,47 @@ const App = () => {
78
77
const { user, isLoading } = useCurrentUser ( )
79
78
80
79
useEffect ( ( ) => {
81
- // Add error handling to prevent app crashes
82
- try {
83
- console . log ( 'Environment check:' , { inCI, inStaging, inProduction, inDevelopment } )
84
-
85
- if ( ! inCI && ! inStaging && ! inDevelopment ) {
86
- console . log ( 'Initializing Shibboleth pinger...' )
87
- initShibbolethPinger ( )
88
- } else {
89
- console . log ( 'Skipping Shibboleth pinger initialization in non-production environments.' )
90
- }
91
- } catch ( error ) {
92
- console . error ( 'Error initializing Shibboleth pinger:' , error )
93
- // Don't let this crash the app
94
- }
80
+ initShibbolethPinger ( )
95
81
} , [ ] )
96
82
97
83
const onNoAccessPage = location . pathname . includes ( '/noaccess' )
98
84
99
- // if (isLoading && !onNoAccessPage) return null
100
- //
101
- // if (!onNoAccessPage && !hasAccess(user, courseId)) {
102
- // window.location.href = PUBLIC_URL + getRedirect(user)
103
- // return null
104
- // }
85
+ if ( isLoading && ! onNoAccessPage ) return null
86
+
87
+ if ( ! onNoAccessPage && ! hasAccess ( user , courseId ) ) {
88
+ window . location . href = PUBLIC_URL + getRedirect ( user )
89
+ return null
90
+ }
105
91
106
92
if ( ! user && ! onNoAccessPage ) return null
107
93
108
94
return (
109
- < ErrorBoundary >
110
- < ThemeProvider theme = { theme } >
111
- < CssBaseline />
112
- < LocalizationProvider dateAdapter = { AdapterDateFns } adapterLocale = { fi } >
113
- < SnackbarProvider preventDuplicate >
114
- < AppContext . Provider value = { appRef } >
115
- < Box
116
- sx = { {
117
- display : 'flex' ,
118
- flexDirection : 'column' ,
119
- minHeight : '100vh' ,
120
- height : '100vh' ,
121
- overflowY : 'auto' , // deleting this will break the auto scroll on chats
122
- } }
123
- ref = { appRef }
124
- >
125
- < NavBar />
126
- < Box sx = { { flex : 1 } } >
127
- < Outlet />
128
- </ Box >
129
- < Footer />
95
+ < ThemeProvider theme = { theme } >
96
+ < CssBaseline />
97
+ < LocalizationProvider dateAdapter = { AdapterDateFns } adapterLocale = { fi } >
98
+ < SnackbarProvider preventDuplicate >
99
+ < AppContext . Provider value = { appRef } >
100
+ < Box
101
+ sx = { {
102
+ display : 'flex' ,
103
+ flexDirection : 'column' ,
104
+ minHeight : '100vh' ,
105
+ height : '100vh' ,
106
+ overflowY : 'auto' , // deleting this will break the auto scroll on chats
107
+ } }
108
+ ref = { appRef }
109
+ >
110
+ < NavBar />
111
+ < Box sx = { { flex : 1 } } >
112
+ < Outlet />
130
113
</ Box >
131
- < AdminLoggedInAsBanner />
132
- </ AppContext . Provider >
133
- </ SnackbarProvider >
134
- </ LocalizationProvider >
135
- </ ThemeProvider >
136
- </ ErrorBoundary >
114
+ < Footer />
115
+ </ Box >
116
+ < AdminLoggedInAsBanner />
117
+ </ AppContext . Provider >
118
+ </ SnackbarProvider >
119
+ </ LocalizationProvider >
120
+ </ ThemeProvider >
137
121
)
138
122
}
139
123
0 commit comments