-
Notifications
You must be signed in to change notification settings - Fork 180
/
Copy pathmain.tsx
58 lines (52 loc) · 1.36 KB
/
main.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
import { StrictMode } from 'react'
import ReactDOM from 'react-dom/client'
import { I18nextProvider } from 'react-i18next'
import { Auth0Provider } from '@auth0/auth0-react'
import { GlobalStyle } from './atoms/GlobalStyle'
import { i18n } from './i18n'
import { App } from './App'
import {
AUTH0_DOMAIN,
LOCAL_AUTH0_DOMAIN,
PROD_AUTH0_CLIENT_ID,
STAGING_AUTH0_CLIENT_ID,
LOCAL_AUTH0_CLIENT_ID,
} from './resources/constants'
const rootElement = document.getElementById('root')
const getClientId = (): string => {
switch (process.env.NODE_ENV) {
case 'production':
return PROD_AUTH0_CLIENT_ID
case 'development':
return LOCAL_AUTH0_CLIENT_ID
default:
return STAGING_AUTH0_CLIENT_ID
}
}
const getDomain = (): string => {
return process.env.NODE_ENV === 'development'
? LOCAL_AUTH0_DOMAIN
: AUTH0_DOMAIN
}
if (rootElement != null) {
const clientId = getClientId()
const domain = getDomain()
ReactDOM.createRoot(rootElement).render(
<StrictMode>
<Auth0Provider
clientId={clientId}
domain={domain}
authorizationParams={{
redirect_uri: window.location.origin,
}}
>
<GlobalStyle />
<I18nextProvider i18n={i18n}>
<App />
</I18nextProvider>
</Auth0Provider>
</StrictMode>
)
} else {
console.error('Root element not found')
}