"use client"; import { useCallback, useEffect } from "react"; import { usePathname, useRouter } from "next/navigation"; type NavItem = { id: string; label: string; href?: string }; const NAV_ITEMS: NavItem[] = [ { id: "overview", label: "Academy" }, { id: "ebook", label: "Book" }, { id: "translate", label: "Translate", href: "/translate" }, { id: "projects", label: "Projects" }, { id: "sermon", label: "Sermon" }, ]; /** Overview — mission control hub */ function IconGrid() { return ( ); } /** Ebook — audio to ebook production */ function IconEbook() { return ( ); } /** Projects — saved workspace archive */ function IconProjects() { return ( ); } /** Translate — standalone translation pipeline */ function IconTranslate() { return ( ); } /** Sermon — live sermon restructuring assistant */ function IconSermon() { return ( ); } const NAV_ICONS: Record React.JSX.Element> = { overview: IconGrid, ebook: IconEbook, translate: IconTranslate, projects: IconProjects, sermon: IconSermon, }; type NexusNavProps = { active: string; onSelect: (id: string) => void; }; function IconLogout() { return ( ); } export function NexusNav({ active, onSelect }: NexusNavProps) { const pathname = usePathname(); const router = useRouter(); const navigateTo = useCallback((href: string) => { // Skip redundant pushes to avoid unnecessary route remounts. if (href === "/translate" && pathname.startsWith("/translate")) return; if (href.startsWith("/ebook") && pathname.startsWith("/ebook")) return; if (href === "/" && pathname === "/") return; router.push(href); }, [pathname, router]); useEffect(() => { router.prefetch("/"); router.prefetch("/ebook?tab=pipeline"); router.prefetch("/translate"); }, [router]); const handleLogout = useCallback(async () => { await fetch("/api/auth/logout", { method: "POST" }); router.push("/login"); }, [router]); const LogoMark = () => (
); return ( <> {/* ── Desktop sidebar (lg+) ─────────────────────────────── */} {/* ── Mobile bottom bar ( {/* Logo tap — goes to overview */} {/* Logout — far right of mobile bar */} {NAV_ITEMS.map((item) => { const Icon = NAV_ICONS[item.id] ?? IconGrid; const isAcademyGroup = item.id === "overview"; const isActive = item.href ? pathname.startsWith(item.href) : isAcademyGroup ? active !== "ebook" && active !== "sermon" && active !== "projects" && active !== "translate" : active === item.id; const inner = ( <> {item.label} ); return ( ); })} ); }