mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 13:00:39 +03:00
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
'use client';
|
|
|
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
import { IntlProvider } from 'react-intl';
|
|
import { pdfjs } from 'react-pdf';
|
|
|
|
import { AuthState } from '@/context/AuthContext';
|
|
import { LibraryState } from '@/context/LibraryContext';
|
|
import { ThemeState } from '@/context/ThemeContext';
|
|
import { UsersState } from '@/context/UsersContext';
|
|
|
|
import ErrorFallback from './components/ErrorFallback';
|
|
|
|
pdfjs.GlobalWorkerOptions.workerSrc = new URL('pdfjs-dist/build/pdf.worker.min.js', import.meta.url).toString();
|
|
|
|
const resetState = () => {
|
|
console.log('Resetting state after error fallback');
|
|
};
|
|
|
|
const logError = (error: Error, info: { componentStack?: string | null | undefined }) => {
|
|
console.log('Error fallback: ' + error.message);
|
|
if (info.componentStack) {
|
|
console.log('Component stack: ' + info.componentStack);
|
|
}
|
|
};
|
|
|
|
// prettier-ignore
|
|
function GlobalProviders({ children }: { children: React.ReactNode }) {
|
|
return (
|
|
<ErrorBoundary
|
|
FallbackComponent={ErrorFallback}
|
|
onReset={resetState}
|
|
onError={logError}
|
|
>
|
|
<IntlProvider locale='ru' defaultLocale='ru'>
|
|
<ThemeState>
|
|
<UsersState>
|
|
<AuthState>
|
|
<LibraryState>
|
|
|
|
{children}
|
|
|
|
</LibraryState>
|
|
</AuthState>
|
|
</UsersState>
|
|
</ThemeState>
|
|
</IntlProvider>
|
|
</ErrorBoundary>);
|
|
}
|
|
|
|
export default GlobalProviders;
|