Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.

Commit 330f644

Browse files
Fir route redirection for {stream}/config path (#109)
1 parent bb1b582 commit 330f644

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/components/Navbar/index.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
} from '@tabler/icons-react';
2525
import { FC, useEffect } from 'react';
2626
import { useNavbarStyles } from './styles';
27-
import { useParams } from 'react-router-dom';
27+
import { useLocation, useParams } from 'react-router-dom';
2828
import { useGetLogStreamList } from '@/hooks/useGetLogStreamList';
2929
import { notifications } from '@mantine/notifications';
3030
import { useNavigate } from 'react-router-dom';
@@ -48,6 +48,7 @@ type NavbarProps = Omit<MantineNavbarProps, 'children'>;
4848
const Navbar: FC<NavbarProps> = (props) => {
4949
const navigate = useNavigate();
5050
const { streamName } = useParams();
51+
const location = useLocation();
5152

5253
const [username] = useLocalStorage({ key: 'username', getInitialValueInEffect: false });
5354
const [, , removeCredentials] = useLocalStorage({ key: 'credentials' });
@@ -65,7 +66,7 @@ const Navbar: FC<NavbarProps> = (props) => {
6566

6667
const [disableLink, setDisableLink] = useMountedState(false);
6768
const [isSubNavbarOpen, setIsSubNavbarOpen] = useMountedState(false);
68-
const [opened, { open, close }] = useDisclosure(true);
69+
const [opened, { open, close }] = useDisclosure(false);
6970
const [openedDelete, { close: closeDelete, open: openDelete }] = useDisclosure();
7071

7172
const { data: streams, error, getData, resetData: resetStreamArray } = useGetLogStreamList();
@@ -94,6 +95,9 @@ const Navbar: FC<NavbarProps> = (props) => {
9495
} = useHeaderContext();
9596

9697
useEffect(() => {
98+
if (location.pathname.split('/')[2]) {
99+
setCurrentPage(`/${location.pathname.split('/')[2]}`);
100+
}
97101
if (streams && streams.length === 0) {
98102
setActiveStream('');
99103
setSearchValue('');
@@ -204,7 +208,8 @@ const Navbar: FC<NavbarProps> = (props) => {
204208
setCurrentPage(link.pathname);
205209
}}
206210
key={link.label}
207-
className={(currentPage === link.pathname && linkBtnActive) || linkBtn}
211+
212+
className={(currentPage === link.pathname && linkBtnActive ) || linkBtn}
208213
/>
209214
);
210215
})}

0 commit comments

Comments
 (0)