fix nav eleements confuse

This commit is contained in:
Primakov Alexandr Alexandrovich 2025-02-10 18:38:40 +03:00
parent 22a76efc1f
commit 530d172f0b
5 changed files with 853 additions and 1031 deletions

1847
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -14,12 +14,12 @@
"license": "ISC",
"description": "",
"dependencies": {
"@brojs/cli": "^1.3.0",
"@brojs/cli": "1.8.4",
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"express": "^4.19.2",
"express": "^4.21.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.27.0"

View File

@ -1,18 +1,19 @@
import { getNavigationsValue } from "@brojs/cli";
import { getNavigationValue } from "@brojs/cli";
import { generatePath } from "react-router-dom";
const baseUrl = getNavigationsValue("nav1.main");
export const URLs = {
baseUrl: getNavigationValue('nav1.main'),
profile: {
isOn: Boolean(getNavigationsValue("link.nav1.profile")),
url: `${baseUrl}${getNavigationsValue("link.nav1.profile")}`,
isOn: Boolean(getNavigationValue("link.nav1.profile")),
url: `${getNavigationValue('nav1.main')}${getNavigationValue("link.nav1.profile")}`,
getUrl(userId: string, projectId: string) {
return generatePath(this.url, { userId, projectId });
},
},
about: {
url: `${baseUrl}${getNavigationsValue("link.nav1.about")}`,
isOn: Boolean(getNavigationValue("link.nav1.about")),
url: `${getNavigationValue('nav1.main')}${getNavigationValue("link.nav1.about")}`,
getUrl() {
return this.url;
},

View File

@ -1,5 +1,5 @@
import React from "react";
import { BrowserRouter, HashRouter } from "react-router-dom";
import { BrowserRouter } from "react-router-dom";
import { ThemeProvider } from "@emotion/react";
import { Dashboard } from "./dashboard";

View File

@ -1,5 +1,5 @@
import React, { Suspense } from "react";
import { Routes, Route } from "react-router-dom";
import React, { Suspense, useEffect } from "react";
import { Routes, Route, useNavigate } from "react-router-dom";
import { URLs } from "./__data__/urls";
import { ProfilePage, AboutPage } from "./pages";
@ -11,9 +11,25 @@ const PageWrapper = ({ children }) => (
</ErrorBoundary>
);
const Redirect = ({ to }: { to: string }) => {
const navigate = useNavigate();
useEffect(() => {
navigate(to)
}, [navigate])
return null
}
export const Dashboard = () => {
return (
<Routes>
<Route
path={URLs.baseUrl}
element={(
<Redirect to={URLs.about.getUrl()} />
)}
/>
<Route
path={URLs.about.url}
element={