From a03a9bb4ab5c6000d31859c2d1726b4f82e7ea8a Mon Sep 17 00:00:00 2001 From: Cho Young-Hwi Date: Tue, 31 Mar 2026 22:43:54 +0100 Subject: [PATCH 1/3] [#685] Update nav links, redirects, and cleanup - Nav: Replace "Writer" and "Reader" with single "Dashboard" link - Dashboard links to /profile/[connected-address] when connected, falls back to /writer redirect when not connected - Dashboard highlights when on any /profile/ page - Update NavBar test to reflect new nav structure + add wagmi mock Co-Authored-By: Claude Opus 4.6 (1M context) --- src/components/NavBar.tsx | 40 +++++++++++++++--------- src/components/__tests__/NavBar.test.tsx | 8 +++-- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/components/NavBar.tsx b/src/components/NavBar.tsx index ed2879ae..a2543462 100644 --- a/src/components/NavBar.tsx +++ b/src/components/NavBar.tsx @@ -3,20 +3,32 @@ import { useState } from "react"; import Link from "next/link"; import { usePathname } from "next/navigation"; +import { useAccount } from "wagmi"; import Image from "next/image"; import { ConnectWallet } from "./ConnectWallet"; -const NAV_LINKS = [ - { href: "/create", label: "Create" }, - { href: "/dashboard/writer", label: "Writer" }, - { href: "/dashboard/reader", label: "Reader" }, - { href: "/agents", label: "Agents" }, - { href: "/token", label: "$PLOT" }, -] as const; - export function NavBar() { const pathname = usePathname(); const [mobileOpen, setMobileOpen] = useState(false); + const { address, isConnected } = useAccount(); + + const dashboardHref = isConnected && address + ? `/profile/${address}` + : "/dashboard/writer"; + + const navLinks = [ + { href: "/create", label: "Create" }, + { href: dashboardHref, label: "Dashboard" }, + { href: "/agents", label: "Agents" }, + { href: "/token", label: "$PLOT" }, + ]; + + const isActive = (href: string) => { + if (href.startsWith("/profile/")) { + return pathname.startsWith("/profile/"); + } + return pathname === href || pathname.startsWith(href + "/"); + }; return (