Initial commit
This commit is contained in:
99
src/Routes/Routes.tsx
Executable file
99
src/Routes/Routes.tsx
Executable file
@@ -0,0 +1,99 @@
|
||||
import { createBrowserRouter } from "react-router";
|
||||
import MainPage from "Pages/MainPage/MainPage";
|
||||
import { baseUrl } from "../GlobalVars";
|
||||
import App from "../App";
|
||||
import ErrorPage from "./ErrorPage";
|
||||
import DocumentationPage from "Pages/DocumentationPage/DocumentationPage";
|
||||
import { IconHome } from "@tabler/icons-react";
|
||||
import type { ReactElement } from "react";
|
||||
import MoleculeEditorPage from "Pages/ExperimentsPage/MoleculePage";
|
||||
import TeamsPage from "Pages/TeamsPage/TeamsPage";
|
||||
import UserPage from "Pages/UserPage/UserPage";
|
||||
import ExperimentPage from "Pages/ExperimentsPage/ExperimentPage";
|
||||
import ExperimentsPage from "Pages/ExperimentsPage/ExperimentsPage";
|
||||
import AuthGuard from "./RouterAuhGuard";
|
||||
|
||||
export const routes: {
|
||||
[id: string]: { path: string; breadcrumbs: (path: string) => ReactElement[] };
|
||||
} = {
|
||||
MainPage: { path: "/", breadcrumbs: () => [<IconHome />] },
|
||||
DocumentationPage: {
|
||||
path: "/documentation",
|
||||
breadcrumbs: () => [<>Документация</>],
|
||||
},
|
||||
ExperimentsPage: {
|
||||
path: "/experiments",
|
||||
breadcrumbs: () => [<>Эксперименты</>],
|
||||
},
|
||||
ExperimentPage: {
|
||||
path: "/experiments/:experiment_id",
|
||||
breadcrumbs: (path: string) => [
|
||||
<>Эксперимент #{path.split("/")[path.split("/").length - 1]}</>,
|
||||
],
|
||||
},
|
||||
MoleculePage: {
|
||||
path: "/experiments/:experiment_id/:molecule_id",
|
||||
breadcrumbs: (path: string) => [
|
||||
<>Молекула #{path.split("/")[path.split("/").length - 1]}</>,
|
||||
],
|
||||
},
|
||||
MachinesPage: {
|
||||
path: "/machines",
|
||||
breadcrumbs: () => [<>Вычислительные системы</>],
|
||||
},
|
||||
TeamsPage: { path: "/teams", breadcrumbs: () => [<>Команды</>] },
|
||||
ErrorPage: { path: "/*", breadcrumbs: () => [<>Ошибка</>] },
|
||||
SettingsPage: { path: "/settings", breadcrumbs: () => [<>Настройки</>] },
|
||||
};
|
||||
|
||||
const router = createBrowserRouter(
|
||||
[
|
||||
{
|
||||
path: "/",
|
||||
element: <App />,
|
||||
children: [
|
||||
{
|
||||
path: routes.MainPage.path,
|
||||
Component: MainPage,
|
||||
},
|
||||
{
|
||||
path: routes.DocumentationPage.path,
|
||||
Component: DocumentationPage,
|
||||
},
|
||||
{
|
||||
path: routes.SettingsPage.path,
|
||||
Component: UserPage,
|
||||
},
|
||||
|
||||
{
|
||||
element: <AuthGuard />, // 🔒 everything below requires auth
|
||||
children: [
|
||||
{
|
||||
path: routes.ExperimentsPage.path,
|
||||
Component: ExperimentsPage,
|
||||
},
|
||||
{
|
||||
path: routes.ExperimentPage.path,
|
||||
Component: ExperimentPage,
|
||||
},
|
||||
{
|
||||
path: routes.MoleculePage.path,
|
||||
Component: MoleculeEditorPage,
|
||||
},
|
||||
{
|
||||
path: routes.TeamsPage.path,
|
||||
Component: TeamsPage,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
path: routes.ErrorPage.path,
|
||||
Component: ErrorPage,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
{ basename: baseUrl },
|
||||
);
|
||||
export default router;
|
||||
Reference in New Issue
Block a user