import { CssBaseline, ThemeProvider } from "@mui/material";
import { LocalizationProvider } from "@mui/x-date-pickers";
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
import { ruRU } from '@mui/x-date-pickers/locales';
import dayjs from "dayjs";
import "dayjs/locale/ru";
import { SnackbarProvider } from 'notistack';
import { BrowserRouter } from "react-router-dom";
import { SWRConfig } from "swr";
import { ViewPage } from "./pages/ViewPublicationPage";
import lightTheme from "./utils/themes/light";


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

export default function App() {

    return (
        <SWRConfig value={{
            revalidateOnFocus: false,
            shouldRetryOnError: false,
        }}>
            <LocalizationProvider dateAdapter={AdapterDayjs} adapterLocale="ru" localeText={localeText}>
                <ThemeProvider theme={lightTheme}>
                    <BrowserRouter>
                        <SnackbarProvider
                            preventDuplicate={true}
                            style={{ backgroundColor: lightTheme.palette.brightPurple.main }}
                        >
                            <CssBaseline />
                            <ViewPage />
                        </SnackbarProvider>
                    </BrowserRouter>
                </ThemeProvider>
            </LocalizationProvider>
        </SWRConfig>
    );
}
