TTime/frontend/src/main.tsx

136 lines
4.1 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 AdminManageProjects from "./Pages/AdminPages/AdminManageProjects.tsx";
import AdminAddProject from "./Pages/AdminPages/AdminAddProject.tsx";
import AdminAddUser from "./Pages/AdminPages/AdminAddUser.tsx";
import AdminProjectAddMember from "./Pages/AdminPages/AdminProjectAddMember.tsx";
import AdminProjectStatistics from "./Pages/AdminPages/AdminProjectStatistics.tsx";
2024-03-18 19:36:28 +01:00
import NotFoundPage from "./Pages/NotFoundPage.tsx";
import UnauthorizedPage from "./Pages/UnauthorizedPage.tsx";
2024-03-21 13:58:45 +01:00
import PMViewOtherUsersTR from "./Pages/ProjectManagerPages/PMViewOtherUsersTR.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 />,
},
{
2024-03-18 15:46:23 +01:00
path: "/yourProjects",
2024-03-18 15:33:19 +01:00
element: <YourProjectsPage />,
},
{
2024-03-18 21:52:34 +01:00
path: "/project/:projectName",
element: <UserProjectPage />,
2024-03-18 15:33:19 +01:00
},
{
2024-03-18 21:52:34 +01:00
path: "/newTimeReport/:projectName",
2024-03-18 15:33:19 +01:00
element: <UserNewTimeReportPage />,
},
{
2024-03-19 11:09:35 +01:00
path: "/timeReports/:projectName",
2024-03-18 21:52:34 +01:00
element: <UserViewTimeReportsPage />,
2024-03-18 15:33:19 +01:00
},
{
2024-03-28 12:09:16 +01:00
path: "/editTimeReport/:projectName/:fetchedWeek",
2024-03-18 21:52:34 +01:00
element: <UserEditTimeReportPage />,
2024-03-14 14:59:57 +01:00
},
2024-03-18 00:40:42 +01:00
{
path: "/changeRole/:projectName/:username",
2024-03-18 15:33:19 +01:00
element: <PMChangeRole />,
},
{
2024-03-21 13:58:45 +01:00
path: "/otherUsersTimeReports/:projectName/:username",
2024-03-18 15:33:19 +01:00
element: <PMOtherUsersTR />,
},
2024-03-21 13:58:45 +01:00
{
path: "/editOthersTR/:projectName/:username/:fetchedWeek",
element: <PMViewOtherUsersTR />,
},
2024-03-18 15:33:19 +01:00
{
path: "/projectMembers/:projectName",
2024-03-18 15:33:19 +01:00
element: <PMProjectMembers />,
},
{
path: "/PMProjectPage/:projectName",
2024-03-18 15:33:19 +01:00
element: <PMProjectPage />,
},
{
2024-03-20 16:36:32 +01:00
path: "/PMTimeActivity/:projectName",
2024-03-18 15:33:19 +01:00
element: <PMTotalTimeActivity />,
},
{
2024-03-20 16:24:10 +01:00
path: "/PMTimeRole/:projectName",
2024-03-18 15:33:19 +01:00
element: <PMTotalTimeRole />,
2024-03-18 00:40:42 +01:00
},
{
path: "/unsignedReports/:projectName",
2024-03-18 15:33:19 +01:00
element: <PMUnsignedReports />,
},
{
2024-03-21 13:58:45 +01:00
path: "/PMViewUnsignedReport/:projectName/:username/:fetchedWeek",
2024-03-18 15:33:19 +01:00
element: <PMViewUnsignedReport />,
},
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: "/adminProjectStatistics",
2024-03-18 15:33:19 +01:00
element: <AdminProjectStatistics />,
},
{
2024-03-18 15:46:23 +01:00
path: "/addProject",
element: <AdminAddProject />,
},
{
path: "/adminAddUser",
element: <AdminAddUser />,
},
{
path: "/adminManageProject",
element: <AdminManageProjects />,
},
{
path: "/adminManageUser",
element: <AdminManageUsers />,
},
{
2024-03-19 22:51:54 +01:00
path: "/unauthorized",
element: <UnauthorizedPage />,
},
]);
// 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>,
);