-
Notifications
You must be signed in to change notification settings - Fork 729
/
index.tsx
61 lines (55 loc) · 2.02 KB
/
index.tsx
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
56
57
58
59
60
61
import React from 'react';
import ReactDOM from 'react-dom';
import { CssBaseline } from '@material-ui/core';
import { MuiThemeProvider } from '@material-ui/core/styles';
import App from './App';
import AppStateProvider, { useAppState } from './state';
import { BrowserRouter as Router, Redirect, Route, Switch } from 'react-router-dom';
import ErrorDialog from './components/ErrorDialog/ErrorDialog';
import LoginPage from './components/LoginPage/LoginPage';
import PrivateRoute from './components/PrivateRoute/PrivateRoute';
import theme from './theme';
import './types';
import { ChatProvider } from './components/ChatProvider';
import { ParticipantProvider } from './components/ParticipantProvider';
import { VideoProvider } from './components/VideoProvider';
import useConnectionOptions from './utils/useConnectionOptions/useConnectionOptions';
import UnsupportedBrowserWarning from './components/UnsupportedBrowserWarning/UnsupportedBrowserWarning';
const VideoApp = () => {
const { error, setError } = useAppState();
const connectionOptions = useConnectionOptions();
return (
<VideoProvider options={connectionOptions} onError={setError}>
<ErrorDialog dismissError={() => setError(null)} error={error} />
<ParticipantProvider>
<ChatProvider>
<App />
</ChatProvider>
</ParticipantProvider>
</VideoProvider>
);
};
export const ReactApp = () => (
<MuiThemeProvider theme={theme}>
<CssBaseline />
<UnsupportedBrowserWarning>
<Router>
<AppStateProvider>
<Switch>
<PrivateRoute exact path="/">
<VideoApp />
</PrivateRoute>
<PrivateRoute path="/room/:URLRoomName">
<VideoApp />
</PrivateRoute>
<Route path="/login">
<LoginPage />
</Route>
<Redirect to="/" />
</Switch>
</AppStateProvider>
</Router>
</UnsupportedBrowserWarning>
</MuiThemeProvider>
);
ReactDOM.render(<ReactApp />, document.getElementById('root'));