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 App from "./App";
import dayjs from "dayjs";
import "dayjs/locale/ru";
import { SnackbarProvider } from 'notistack';
import { createRoot } from "react-dom/client";
import "./index.css";
import lightTheme from "./utils/themes/light";
import { SWRConfig } from "swr";
import {BrowserRouter} from "react-router-dom";



dayjs.locale("ru");

const localeText = ruRU.components.MuiLocalizationProvider.defaultProps.localeText;

const root = createRoot(document.getElementById("root")!);

root.render(
    <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 />
                            <App />
                        </SnackbarProvider>
                    </BrowserRouter>
                </ThemeProvider>
            </LocalizationProvider>
    </SWRConfig>
);
