diff --git a/components/NavItem.tsx b/components/NavItem.tsx index 5868b71..57c87b4 100644 --- a/components/NavItem.tsx +++ b/components/NavItem.tsx @@ -1,16 +1,17 @@ import Image from "next/image"; +import Link from "next/link"; interface NavItemProps { icon: string; label: string; isActive: boolean; - onClick: () => void; + href: string; } -export default function NavItem({ icon, label, isActive, onClick }: NavItemProps) { +export default function NavItem({ icon, label, isActive, href }: NavItemProps) { return ( - + ); } diff --git a/components/Sidebar.tsx b/components/Sidebar.tsx index 23c8fb9..6639ff0 100644 --- a/components/Sidebar.tsx +++ b/components/Sidebar.tsx @@ -1,16 +1,16 @@ "use client"; import Image from "next/image"; -import { useState } from "react"; +import { usePathname } from "next/navigation"; import NavItem from "./NavItem"; import { useApp } from "@/contexts/AppContext"; export default function Sidebar() { const { t } = useApp(); - const [activeItem, setActiveItem] = useState("Assets"); + const pathname = usePathname(); const navigationItems = [ - { icon: "/icon-assets.svg", label: t("nav.assets"), key: "Assets", path: "/" }, + { icon: "/icon-assets.svg", label: t("nav.assets"), key: "Assets", path: "/product" }, { icon: "/icon-alp.svg", label: t("nav.alp"), key: "ALP", path: "/alp" }, { icon: "/icon-swap.svg", label: t("nav.swap"), key: "Swap", path: "/swap" }, { icon: "/icon-lending.svg", label: t("nav.lending"), key: "Lending", path: "/lending" }, @@ -39,8 +39,8 @@ export default function Sidebar() { key={item.key} icon={item.icon} label={item.label} - isActive={activeItem === item.key} - onClick={() => setActiveItem(item.key)} + isActive={pathname === item.path} + href={item.path} /> ))}