import { CssBaseline, ThemeProvider } from "@mui/material";
import { LocalizationProvider } from "@mui/x-date-pickers";
import { AdapterMoment } from "@mui/x-date-pickers/AdapterMoment";
import { ruRU } from '@mui/x-date-pickers/locales';
import ErrorBoundaryFallback from "@ui_kit/ErrorBoundaryFallback";
import LoadingSkeleton from "@ui_kit/LoadingSkeleton";
import { handleComponentError } from "@utils/handleComponentError";
import moment from "moment";
import { SnackbarProvider } from 'notistack';
import { Suspense } from "react";
import { ErrorBoundary } from "react-error-boundary";
import { SWRConfig } from "swr";
import ViewPublicationPage from "./pages/ViewPublicationPage/ViewPublicationPage";
import lightTheme from "./utils/themes/light";


moment.locale("ru");
const localeText = ruRU.components.MuiLocalizationProvider.defaultProps.localeText;

export default function QuizAnswerer() {

    return (
        <SWRConfig value={{
            revalidateOnFocus: false,
            shouldRetryOnError: false,
        }}>
            <LocalizationProvider dateAdapter={AdapterMoment} adapterLocale="ru" localeText={localeText}>
                <ThemeProvider theme={lightTheme}>
                    <SnackbarProvider
                        preventDuplicate={true}
                        style={{ backgroundColor: lightTheme.palette.brightPurple.main }}
                    >
                        <CssBaseline />
                        <ErrorBoundary
                            FallbackComponent={ErrorBoundaryFallback}
                            onError={handleComponentError}
                        >
                            <Suspense fallback={<LoadingSkeleton />}>
                                <ViewPublicationPage />
                            </Suspense>
                        </ErrorBoundary>
                    </SnackbarProvider>
                </ThemeProvider>
            </LocalizationProvider>
        </SWRConfig>
    );
} 
