TTime/frontend/src/main.tsx

164 lines
4.7 KiB
TypeScript
Raw Normal View History

import React from "react";
import ReactDOM from "react-dom/client";
import "./index.css";
import { createBrowserRouter, RouterProvider } from "react-router-dom";
2024-03-17 10:33:37 +01:00
import App from "./Pages/App";
2024-03-18 15:33:19 +01:00
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";
import AdminViewUserInfo from "./Pages/AdminPages/AdminViewUserInfo.tsx";
import AdminManageProjects from "./Pages/AdminPages/AdminManageProjects.tsx";
import AdminAddProject from "./Pages/AdminPages/AdminAddProject.tsx";
import AdminAddUser from "./Pages/AdminPages/AdminAddUser.tsx";
import AdminChangeUsername from "./Pages/AdminPages/AdminChangeUsername.tsx";
import AdminProjectAddMember from "./Pages/AdminPages/AdminProjectAddMember.tsx";
import AdminProjectChangeUserRole from "./Pages/AdminPages/AdminProjectChangeUserRole.tsx";
import AdminProjectManageMembers from "./Pages/AdminPages/AdminProjectManageMembers.tsx";
import AdminProjectStatistics from "./Pages/AdminPages/AdminProjectStatistics.tsx";
import AdminProjectViewMemberInfo from "./Pages/AdminPages/AdminProjectViewMemberInfo.tsx";
import AdminProjectPage from "./Pages/AdminPages/AdminProjectPage.tsx";
2024-03-18 19:36:28 +01:00
import NotFoundPage from "./Pages/NotFoundPage.tsx";
// This is where the routes are mounted
const router = createBrowserRouter([
2024-03-18 15:39:29 +01:00
{
path: "/",
element: <App />,
2024-03-18 19:36:28 +01:00
errorElement: <NotFoundPage />,
2024-03-18 15:39:29 +01:00
},
{
path: "/admin",
element: <AdminMenuPage />,
},
{
path: "/pm",
element: <YourProjectsPage />,
},
{
path: "/user",
element: <YourProjectsPage />,
},
{
2024-03-18 15:46:23 +01:00
path: "/yourProjects",
2024-03-18 15:33:19 +01:00
element: <YourProjectsPage />,
},
{
2024-03-18 15:46:23 +01:00
path: "/editTimeReport",
2024-03-18 15:33:19 +01:00
element: <UserEditTimeReportPage />,
},
{
2024-03-18 15:46:23 +01:00
path: "/newTimeReport",
2024-03-18 15:33:19 +01:00
element: <UserNewTimeReportPage />,
},
{
path: "/project",
element: <UserProjectPage />,
},
{
2024-03-18 15:46:23 +01:00
path: "/projectPage",
2024-03-18 15:33:19 +01:00
element: <UserViewTimeReportsPage />,
2024-03-14 14:59:57 +01:00
},
2024-03-18 00:40:42 +01:00
{
2024-03-18 15:46:23 +01:00
path: "/changeRole",
2024-03-18 15:33:19 +01:00
element: <PMChangeRole />,
},
{
2024-03-18 15:46:23 +01:00
path: "/otherUsersTimeReports",
2024-03-18 15:33:19 +01:00
element: <PMOtherUsersTR />,
},
{
2024-03-18 15:46:23 +01:00
path: "/projectMembers",
2024-03-18 15:33:19 +01:00
element: <PMProjectMembers />,
},
{
2024-03-18 15:46:23 +01:00
path: "/PMProjectPage",
2024-03-18 15:33:19 +01:00
element: <PMProjectPage />,
},
{
2024-03-18 15:46:23 +01:00
path: "/PMTimeActivity",
2024-03-18 15:33:19 +01:00
element: <PMTotalTimeActivity />,
},
{
2024-03-18 15:46:23 +01:00
path: "/PMTimeRole",
2024-03-18 15:33:19 +01:00
element: <PMTotalTimeRole />,
2024-03-18 00:40:42 +01:00
},
{
2024-03-18 15:46:23 +01:00
path: "/PMUnsignedReports",
2024-03-18 15:33:19 +01:00
element: <PMUnsignedReports />,
},
{
2024-03-18 15:46:23 +01:00
path: "/PMViewUnsignedReport",
2024-03-18 15:33:19 +01:00
element: <PMViewUnsignedReport />,
},
{
2024-03-18 15:46:23 +01:00
path: "/adminChangeUsername",
2024-03-18 15:33:19 +01:00
element: <AdminChangeUsername />,
2024-03-18 01:56:04 +01:00
},
2024-03-18 00:40:42 +01:00
{
2024-03-18 15:46:23 +01:00
path: "/adminProjectAddMember",
2024-03-18 15:33:19 +01:00
element: <AdminProjectAddMember />,
},
{
2024-03-18 15:46:23 +01:00
path: "/adminProjectChangeUserRole",
2024-03-18 15:33:19 +01:00
element: <AdminProjectChangeUserRole />,
},
{
2024-03-18 15:46:23 +01:00
path: "/adminProjectManageMembers",
2024-03-18 15:33:19 +01:00
element: <AdminProjectManageMembers />,
},
{
2024-03-18 15:46:23 +01:00
path: "/adminProjectPage",
2024-03-18 15:33:19 +01:00
element: <AdminProjectPage />,
},
{
2024-03-18 15:46:23 +01:00
path: "/adminProjectStatistics",
2024-03-18 15:33:19 +01:00
element: <AdminProjectStatistics />,
},
{
2024-03-18 15:46:23 +01:00
path: "/adminProjectViewMembers",
2024-03-18 15:33:19 +01:00
element: <AdminProjectViewMemberInfo />,
},
{
2024-03-18 15:46:23 +01:00
path: "/addProject",
element: <AdminAddProject />,
},
{
path: "/adminAddUser",
element: <AdminAddUser />,
},
{
path: "/adminUserInfo",
2024-03-18 15:33:19 +01:00
element: <AdminViewUserInfo />,
},
2024-03-18 15:46:23 +01:00
{
path: "/adminManageProject",
element: <AdminManageProjects />,
},
{
path: "/adminManageUser",
element: <AdminManageUsers />,
},
]);
// 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>,
);