import React from "react";
import { createRoot } from "react-dom/client";
import { DndProvider } from "react-dnd";
import { HTML5Backend } from "react-dnd-html5-backend";
import "./index.css";
import { BrowserRouter, Route, Routes } from "react-router-dom";
import lightTheme from "./utils/themes/light";
import { ThemeProvider } from "@mui/material";

import StartPage from "./pages/startPage/StartPage";
import Main from "./pages/main";
import QuestionsPage from "./pages/Questions/QuestionsPage";
import ContactFormPage from "./pages/ContactFormPage/ContactFormPage";
import InstallQuiz from "./pages/InstallQuiz/InstallQuiz";
import { Result } from "./pages/Result/Result";
import { Setting } from "./pages/Result/Setting";
import MyQuizzesFull from "./pages/createQuize/MyQuizzesFull";
import ContactFormModal from "@ui_kit/ContactForm";
import ImageCrop from "@ui_kit/Modal/ImageCrop";
import Landing from "./pages/Landing/Landing";

const routeslink: {
  path: string;
  page: JSX.Element;
  header: boolean;
  sidebar: boolean;
}[] = [
  { path: "/list", page: <MyQuizzesFull />, header: false, sidebar: false },
  { path: "/questions/:quizId", page: <QuestionsPage />, header: true, sidebar: true,},
  { path: "/contacts", page: <ContactFormPage />, header: true, sidebar: true },
  { path: "/result", page: <Result />, header: true, sidebar: true },
  { path: "/settings", page: <Setting />, header: true, sidebar: true },
  { path: "/install", page: <InstallQuiz />, header: true, sidebar: true },
];

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

root.render(
  <DndProvider backend={HTML5Backend}>
    <ThemeProvider theme={lightTheme}>
      <ContactFormModal />
      <BrowserRouter>
        <Routes>
          {routeslink.map((e, i) => (
            <Route key={i} path={e.path} element={<Main page={e.page} header={e.header} sidebar={e.sidebar} />} />
          ))}
          <Route path="quize-setting/:quizId" element={<StartPage />} />
          <Route path="crop" element={<ImageCrop />} />
          <Route path="/" element={<Landing/>}/>
        </Routes>
      </BrowserRouter>
    </ThemeProvider>
  </DndProvider>
);
