import React from "react";
import ReactDOM from "react-dom/client";
import "./index.css";
import { createBrowserRouter, RouterProvider } from "react-router-dom";
import LoginPage from "./Pages/LoginPage.tsx";
import YourProjectsPage from "./Pages/YourProjectsPage.tsx";
import UserProjectPage from "./Pages/UserPages/UserProjectPage.tsx";
import AdminMenuPage from "./Pages/AdminPages/AdminMenuPage.tsx";
import UserEditTimeReportPage from "./Pages/UserPages/UserEditTimeReportPage.tsx";
import UserNewTimeReportPage from "./Pages/UserPages/UserNewTimeReportPage.tsx";
import UserViewTimeReportsPage from "./Pages/UserPages/UserViewTimeReportsPage.tsx";
import PMChangeRole from "./Pages/ProjectManagerPages/PMChangeRole.tsx";
import PMOtherUsersTR from "./Pages/ProjectManagerPages/PMOtherUsersTR.tsx";
import PMProjectMembers from "./Pages/ProjectManagerPages/PMProjectMembers.tsx";
import PMProjectPage from "./Pages/ProjectManagerPages/PMProjectPage.tsx";
import PMTotalTimeActivity from "./Pages/ProjectManagerPages/PMTotalTimeActivity.tsx";
import PMTotalTimeRole from "./Pages/ProjectManagerPages/PMTotalTimeRole.tsx";
import PMUnsignedReports from "./Pages/ProjectManagerPages/PMUnsignedReports.tsx";
import PMViewUnsignedReport from "./Pages/ProjectManagerPages/PMViewUnsignedReport.tsx";
import AdminManageUsers from "./Pages/AdminPages/AdminManageUsers.tsx";

// This is where the routes are mounted
const router = createBrowserRouter([
  {
    path: "/",
    element: <LoginPage />,
  },
  {
    path: "/your-projects",
    element: <YourProjectsPage />,
  },
  {
    path: "/edit-time-report",
    element: <UserEditTimeReportPage />,
  },
  {
    path: "/new-time-report",
    element: <UserNewTimeReportPage />,
  },
  {
    path: "/project",
    element: <UserProjectPage />,
  },
  {
    path: "/project-page",
    element: <UserViewTimeReportsPage />,
  },
  {
    path: "/change-role",
    element: <PMChangeRole />,
  },
  {
    path: "/other-users-time-reports",
    element: <PMOtherUsersTR />,
  },
  {
    path: "/project-members",
    element: <PMProjectMembers />,
  },
  {
    path: "/PM-project-page",
    element: <PMProjectPage />,
  },
  {
    path: "/PM-time-activity",
    element: <PMTotalTimeActivity />,
  },
  {
    path: "/PM-time-role",
    element: <PMTotalTimeRole />,
  },
  {
    path: "/PM-unsigned-reports",
    element: <PMUnsignedReports />,
  },
  {
    path: "/PM-view-unsigned-report",
    element: <PMViewUnsignedReport />,
  },
  {
    path: "/admin-menu",
    element: <AdminMenuPage />,
  },
  {
    path: "/admin-menu",
    element: <AdminMenuPage />,
  },
  {
    path: "/admin-manage-users",
    element: <AdminManageUsers />,
  },
  {
    path: "/admin-menu",
    element: <AdminMenuPage />,
  },
]);

// Semi-hacky way to get the root element
const root = document.getElementById("root") ?? document.createElement("div");

// Render the router at the root
ReactDOM.createRoot(root).render(
  <React.StrictMode>
    <RouterProvider router={router} />
  </React.StrictMode>,
);
