From 17d7b7c41d91d56f8d8604b15b062610504320d9 Mon Sep 17 00:00:00 2001 From: goodmice Date: Tue, 6 Dec 2022 00:23:45 +0500 Subject: [PATCH] =?UTF-8?q?*=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BD=D0=B0=20=D1=81=D1=81=D1=8B=D0=BB=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BC=D0=B5=D1=81=D1=82=D0=BE=D1=80=D0=BE=D0=B6?= =?UTF-8?q?=D0=B4=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B2=20=D0=BF=D0=BE=D0=B4?= =?UTF-8?q?=D1=81=D0=BA=D0=B0=D0=B7=D0=BA=D0=B5=20=D0=B7=D0=BD=D0=B0=D1=87?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BD=D0=B0=20=D0=BA=D0=B0=D1=80=D1=82=D0=B5=20?= =?UTF-8?q?*=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=20=D0=B2=D1=8B=D0=B4=D0=B5=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=20=D0=BC=D0=B5=D1=81=D1=82=D0=BE=D1=80=D0=BE=D0=B6=D0=B4=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=B2=20=D1=81=D0=B5=D0=BB=D0=B5=D0=BA?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Deposit/Map.jsx | 10 +++++++++- src/pages/Deposit/index.jsx | 17 ++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) 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 (