diff --git a/frontend/src/component/commandBar/CommandBar.tsx b/frontend/src/component/commandBar/CommandBar.tsx index 1f6b6a53cb..ccedb0551c 100644 --- a/frontend/src/component/commandBar/CommandBar.tsx +++ b/frontend/src/component/commandBar/CommandBar.tsx @@ -83,6 +83,12 @@ const StyledClose = styled(Close)(({ theme }) => ({ fontSize: theme.typography.body1.fontSize, })); +interface IPageRouteInfo { + path: string; + route: string; + title: string; +} + export const CommandBar = () => { const searchInputRef = useRef(null); const searchContainerRef = useRef(null); @@ -91,12 +97,12 @@ export const CommandBar = () => { const [searchedProjects, setSearchedProjects] = useState< CommandResultGroupItem[] >([]); + const [searchedPages, setSearchedPages] = useState< + CommandResultGroupItem[] + >([]); const { lastVisited } = useRecentlyVisited(); const { routes } = useRoutes(); - const allRoutes: Record< - string, - { path: string; route: string; title: string } - > = {}; + const allRoutes: Record = {}; for (const route of [ ...routes.mainNavRoutes, ...routes.adminRoutes, @@ -139,6 +145,15 @@ export const CommandBar = () => { })); setSearchedProjects(mappedProjects); + + const filteredPages = Object.values(allRoutes).filter((route) => + route.title.toLowerCase().includes(query.toLowerCase()), + ); + const mappedPages = filteredPages.map((page) => ({ + name: page.title, + link: page.path, + })); + setSearchedPages(mappedPages); }, 200); const onSearchChange = (value: string) => { @@ -235,6 +250,11 @@ export const CommandBar = () => { icon={'flag'} items={searchedProjects} /> + } elseShow={