2023-07-26 23:11:00 +03:00
|
|
|
import './index.css'
|
2023-07-25 20:27:29 +03:00
|
|
|
|
|
|
|
import axios from 'axios';
|
2023-07-26 23:11:00 +03:00
|
|
|
import React from 'react'
|
|
|
|
import ReactDOM from 'react-dom/client'
|
2023-07-25 20:27:29 +03:00
|
|
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
|
|
import { IntlProvider } from 'react-intl';
|
2023-07-15 17:46:19 +03:00
|
|
|
import { BrowserRouter } from 'react-router-dom';
|
2023-07-25 20:27:29 +03:00
|
|
|
|
2023-07-26 23:11:00 +03:00
|
|
|
import App from './App.tsx'
|
|
|
|
import ErrorFallback from './components/ErrorFallback.tsx';
|
|
|
|
import { AuthState } from './context/AuthContext.tsx';
|
|
|
|
import { ThemeState } from './context/ThemeContext.tsx';
|
|
|
|
import { UsersState } from './context/UsersContext.tsx';
|
2023-07-15 17:46:19 +03:00
|
|
|
|
2023-07-26 23:11:00 +03:00
|
|
|
axios.defaults.withCredentials = true;
|
|
|
|
axios.defaults.xsrfCookieName = 'csrftoken';
|
|
|
|
axios.defaults.xsrfHeaderName = 'x-csrftoken';
|
2023-07-15 17:46:19 +03:00
|
|
|
|
|
|
|
const resetState = () => {
|
|
|
|
console.log('Resetting state after error fallback')
|
|
|
|
};
|
|
|
|
|
|
|
|
const logError = (error: Error, info: { componentStack: string }) => {
|
|
|
|
console.log('Error fallback: ' + error.message)
|
2023-07-25 20:27:29 +03:00
|
|
|
console.log('Component stack: ' + info.componentStack)
|
2023-07-15 17:46:19 +03:00
|
|
|
};
|
|
|
|
|
2023-07-26 23:11:00 +03:00
|
|
|
ReactDOM.createRoot(document.getElementById('root')!).render(
|
2023-07-15 17:46:19 +03:00
|
|
|
<React.StrictMode>
|
|
|
|
<BrowserRouter>
|
2023-07-25 20:27:29 +03:00
|
|
|
<ErrorBoundary
|
2023-07-15 17:46:19 +03:00
|
|
|
FallbackComponent={ErrorFallback}
|
|
|
|
onReset={resetState}
|
|
|
|
onError={logError}
|
|
|
|
>
|
|
|
|
<IntlProvider locale='ru' defaultLocale='ru'>
|
|
|
|
<ThemeState>
|
|
|
|
<AuthState>
|
|
|
|
<UsersState>
|
|
|
|
<App />
|
|
|
|
</UsersState>
|
|
|
|
</AuthState>
|
|
|
|
</ThemeState>
|
|
|
|
</IntlProvider>
|
|
|
|
</ErrorBoundary>
|
|
|
|
</BrowserRouter>
|
2023-07-26 23:11:00 +03:00
|
|
|
</React.StrictMode>,
|
|
|
|
)
|