"use client"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { useState } from "react"; import { signOut } from "next-auth/react"; import { Logo } from "@/components/Logo"; import { SignOutButton } from "@/components/SignOutButton"; import { MobileMenuButton, MobileSidebar, dashboardSidebarLinkClass } from "@/components/MobileSidebar"; const NAV_LINKS = [ { href: "/dashboard", label: "Create", match: (path: string) => path === "/dashboard" }, { href: "/dashboard/history", label: "History", match: (path: string) => path.startsWith("/dashboard/history"), }, { href: "/dashboard/settings", label: "Settings", match: (path: string) => path.startsWith("/dashboard/settings"), }, ] as const; type Props = { channelTitle?: string | null; }; export function DashboardNav({ channelTitle }: Props) { const pathname = usePathname(); const [menuOpen, setMenuOpen] = useState(false); return ( <> {channelTitle && ( Channel: {channelTitle} )} {NAV_LINKS.map(({ href, label, match }) => { const active = match(pathname); return ( {label} ); })} setMenuOpen((prev) => !prev)} /> setMenuOpen(false)} title="Dashboard"> {NAV_LINKS.map(({ href, label, match }) => ( setMenuOpen(false)} className={dashboardSidebarLinkClass(match(pathname))} > {label} ))} { setMenuOpen(false); signOut({ callbackUrl: "/" }); }} className={`${dashboardSidebarLinkClass(false, true)} w-full text-left`} > Sign out > ); }
Channel: {channelTitle}