diff --git a/src/pages/Deposit/Map.jsx b/src/pages/Deposit/Map.jsx index b849dae..911c137 100644 --- a/src/pages/Deposit/Map.jsx +++ b/src/pages/Deposit/Map.jsx @@ -67,7 +67,15 @@ const Map = memo(() => { return ( - + + {deposit.caption} + + )} + >
diff --git a/src/pages/Deposit/index.jsx b/src/pages/Deposit/index.jsx index b342af2..b0af444 100644 --- a/src/pages/Deposit/index.jsx +++ b/src/pages/Deposit/index.jsx @@ -1,4 +1,4 @@ -import { Navigate, Route, Routes, useLocation, useParams } from 'react-router-dom' +import { Navigate, Route, Routes, useParams } from 'react-router-dom' import { lazy, memo, useEffect, useMemo } from 'react' import { DepositContext, RootPathContext, useDepositList, useLayoutProps, useRootPath } from '@asb/context' @@ -10,11 +10,13 @@ const DepositNavigationMenu = lazy(() => import('./DepositNavigationMenu')) const Deposit = memo(() => { const { '*': param } = useParams() - const location = useLocation() const setLayoutProps = useLayoutProps() const deposits = useDepositList() + const root = useRootPath() + const rootPath = useMemo(() => `${root}/deposit`, [root]) + const idDeposit = useMemo(() => { const result = /^([^\/#?]+)/.exec(param) return result && result[1] !== 'null' ? Number(result[1]) : null @@ -22,15 +24,12 @@ const Deposit = memo(() => { const deposit = useMemo(() => deposits.find((deposit) => deposit.id === idDeposit) || null, [deposits, idDeposit]) - const root = useRootPath() - const rootPath = useMemo(() => `${root}/deposit`, [root]) - useEffect(() => { - const hasId = location.pathname.length > '/deposit/'.length + const key = idDeposit ? `/deposit/${idDeposit}` : null const selectorProps = { - expand: hasId ? [location.pathname] : true, - current: hasId ? location.pathname : undefined, + expand: key ? [key] : true, + current: key || undefined, } setLayoutProps({ @@ -40,7 +39,7 @@ const Deposit = memo(() => { selectorProps, title: 'Месторождение', }) - }, [setLayoutProps, location.pathname, deposit]) + }, [setLayoutProps, idDeposit]) return (