TTime/frontend/src/main.tsx

124 lines
3.6 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";
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";
2024-03-14 10:33:00 +01:00
import UserEditTimeReportPage from "./Pages/UserPages/UserEditTimeReportPage.tsx";
2024-03-14 11:00:46 +01:00
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";
2024-03-14 14:29:10 +01:00
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";
2024-03-14 14:33:43 +01:00
import AdminManageUsers from "./Pages/AdminPages/AdminManageUsers.tsx";
2024-03-14 14:42:26 +01:00
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";
// This is where the routes are mounted
const router = createBrowserRouter([
{
path: "/",
element: <LoginPage />,
},
{
path: "/your-projects",
element: <YourProjectsPage />,
},
2024-03-14 11:00:46 +01:00
{
path: "/edit-time-report",
element: <UserEditTimeReportPage />,
},
{
path: "/new-time-report",
element: <UserNewTimeReportPage />,
},
{
path: "/project",
element: <UserProjectPage />,
},
{
2024-03-14 11:00:46 +01:00
path: "/project-page",
element: <UserViewTimeReportsPage />,
},
2024-03-14 10:33:00 +01:00
{
2024-03-14 11:00:46 +01:00
path: "/change-role",
element: <PMChangeRole />,
},
{
path: "/other-users-time-reports",
element: <PMOtherUsersTR />,
},
{
path: "/project-members",
element: <PMProjectMembers />,
},
{
path: "/PM-project-page",
element: <PMProjectPage />,
2024-03-14 10:33:00 +01:00
},
2024-03-14 14:29:10 +01:00
{
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 />,
},
{
2024-03-14 14:42:26 +01:00
path: "/admin-add-project",
element: <AdminAddProject />,
2024-03-14 14:29:10 +01:00
},
2024-03-14 14:33:43 +01:00
{
2024-03-14 14:42:26 +01:00
path: "/admin-add-user",
element: <AdminAddUser />,
},
{
path: "/admin-change-username",
element: <AdminChangeUsername />,
},
{
path: "/admin-manage-projects",
element: <AdminManageProjects />,
2024-03-14 14:33:43 +01:00
},
{
path: "/admin-manage-users",
element: <AdminManageUsers />,
},
{
path: "/admin-menu",
element: <AdminMenuPage />,
},
2024-03-14 14:42:26 +01:00
{
path: "/admin-view-user",
element: <AdminViewUserInfo />,
},
]);
// 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>,
);