From c04230e0067f23fda05dc35c8f4a411153e81d5d Mon Sep 17 00:00:00 2001 From: MaryWylde Date: Mon, 22 Dec 2025 13:38:41 +0400 Subject: [PATCH] chore: improve active page path logic and change import approach of ToolHeader. --- src/components/ToolHeader/ToolHeader.tsx | 25 +++++++++++++++--------- src/layouts/Layout.tsx | 6 +----- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/components/ToolHeader/ToolHeader.tsx b/src/components/ToolHeader/ToolHeader.tsx index 7971d8f..ef976cd 100644 --- a/src/components/ToolHeader/ToolHeader.tsx +++ b/src/components/ToolHeader/ToolHeader.tsx @@ -98,6 +98,9 @@ const ToolHeader: FC = ({ const [token, setToken] = useState(null); const [usernameIsTakenError, setUsernameIsTakenError] = useState(''); const [changedTitle, setChangedTitle] = useState(false); + const [activePage, setActivePage] = useState< + 'uxcore' | 'uxcg' | 'uxcp' | 'uxcat' + >('uxcore'); const { ourProjects, @@ -140,15 +143,14 @@ const ToolHeader: FC = ({ const title = changedTitle ? userInfo?.title : userInfo?.user?.title; - const activePage = pathname.includes('/uxcore') - ? 'uxcore' - : pathname.includes('/uxcg') - ? 'uxcg' - : pathname.includes('/uxcp') - ? 'uxcp' - : pathname.includes('/uxcat') || pathname.includes('/user') - ? 'uxcat' - : 'uxcore'; + const getActiveFromPath = (pathname: string) => { + if (pathname.includes('/uxcore')) return 'uxcore'; + if (pathname.includes('/uxcg')) return 'uxcg'; + if (pathname.includes('/uxcp')) return 'uxcp'; + if (pathname.includes('/uxcat') || pathname.includes('/user')) + return 'uxcat'; + return null; + }; const openPodcastHandler = useCallback(() => { setOpenPodcast(prev => !prev); @@ -233,6 +235,11 @@ const ToolHeader: FC = ({ } }, [title, locale, userInfo]); + useEffect(() => { + const next = getActiveFromPath(pathname); + if (next) setActivePage(next); + }, [pathname]); + return (