diff --git a/front/components/navigation/NavigationSidebar.tsx b/front/components/navigation/NavigationSidebar.tsx index 115f490a6d89..7e5e42765658 100644 --- a/front/components/navigation/NavigationSidebar.tsx +++ b/front/components/navigation/NavigationSidebar.tsx @@ -5,6 +5,7 @@ import { NavigationListItem, NavigationListLabel, Tabs, + TabsContent, TabsList, TabsTrigger, } from "@dust-tt/sparkle"; @@ -13,11 +14,7 @@ import Link from "next/link"; import { useRouter } from "next/router"; import React, { useCallback, useEffect, useMemo, useState } from "react"; -import type { - AppLayoutNavigation, - SidebarNavigation, - TabAppLayoutNavigation, -} from "@app/components/navigation/config"; +import type { SidebarNavigation } from "@app/components/navigation/config"; import { getTopNavigationTabs } from "@app/components/navigation/config"; import { UserMenu } from "@app/components/UserMenu"; import WorkspacePicker from "@app/components/WorkspacePicker"; @@ -42,9 +39,6 @@ export const NavigationSidebar = React.forwardRef< const router = useRouter(); const { user } = useUser(); const [activePath, setActivePath] = useState(""); - const [currentTab, setCurrentTab] = useState< - TabAppLayoutNavigation | undefined - >(undefined); useEffect(() => { if (router.isReady && router.route) { @@ -52,29 +46,12 @@ export const NavigationSidebar = React.forwardRef< } }, [router.route, router.isReady]); - const nav = useMemo(() => getTopNavigationTabs(owner), [owner]); - - const [navs, setNavs] = useState([]); - - // TODO(2024-06-19 flav): Fix issue with AppLayout changing between pages - useEffect(() => { - setNavs((prevNavs) => { - const newNavs = nav.map((n) => { - const current = n.isCurrent(activePath); - return { ...n, current }; - }); - - const isSameCurrent = - prevNavs.length === newNavs.length && - prevNavs.every((prevNav, index) => { - return prevNav.current === newNavs[index].current; - }); - - const activeTab = nav.filter((n) => n.isCurrent(activePath))[0]; - setCurrentTab(activeTab); - return isSameCurrent ? prevNavs : newNavs; - }); - }, [nav, activePath]); + // TODO(2024-06-19 flav): Fix issue with AppLayout changing between pagesg + const navs = useMemo(() => getTopNavigationTabs(owner), [owner]); + const currentTab = useMemo( + () => navs.find((n) => n.isCurrent(activePath)), + [navs, activePath] + ); return (
)} {subscription.paymentFailingSince && } - {nav.length > 1 && ( + {navs.length > 1 && (
- + {navs.map((tab) => ( ))} - -
- )} - {subNavigation && ( - <> - {subNavigation && ( - <> - {subNavigation.map((nav) => ( -
- - {nav.label && ( - - )} - {nav.menus.map((menu) => ( - - - {menu.subMenuLabel && ( -
- {menu.subMenuLabel} -
- )} - {menu.subMenu && ( -
- {menu.subMenu.map((nav) => ( + {navs.map((tab) => ( + + {subNavigation && tab.isCurrent(activePath) && ( + <> + {subNavigation.map((nav) => ( +
+ + {nav.label && ( + + )} + {nav.menus.map((menu) => ( + - ))} -
- )} - + {menu.subMenuLabel && ( +
+ {menu.subMenuLabel} +
+ )} + {menu.subMenu && ( +
+ {menu.subMenu.map((nav) => ( + + ))} +
+ )} + + ))} + +
))} -
-
- ))} - - )} - + + )} + + ))} + +
)}
{children}