TTime/frontend/src/main.tsx

58 lines
1.4 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";
import AdminMenuPage from "./Pages/AdminPages/AdminMenuPage";
import YourProjectsPage from "./Pages/YourProjectsPage";
2024-03-18 00:40:42 +01:00
import AdminAddProject from "./Pages/AdminPages/AdminAddProject";
import AdminManageProjects from "./Pages/AdminPages/AdminManageProjects";
import AdminManageUsers from "./Pages/AdminPages/AdminManageUsers";
import AdminAddUser from "./Pages/AdminPages/AdminAddUser";
// This is where the routes are mounted
const router = createBrowserRouter([
{
path: "/",
2024-03-17 10:33:37 +01:00
element: <App />,
},
{
2024-03-17 10:33:37 +01:00
path: "/admin",
2024-03-14 14:33:43 +01:00
element: <AdminMenuPage />,
},
2024-03-14 14:59:57 +01:00
{
2024-03-17 10:33:37 +01:00
path: "/pm",
element: <YourProjectsPage />,
2024-03-14 14:59:57 +01:00
},
2024-03-18 00:40:42 +01:00
{
path: "/user",
element: <YourProjectsPage />,
},
{
path: "/addProject",
element: <AdminAddProject />,
},
{
path: "/adminAddUser",
element: <AdminAddUser />,
},
{
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>,
);