'use client' import Link from 'next/link' import Image from 'next/image' import { usePathname } from 'next/navigation' import { useStore } from '@/lib/store' import { Eye, TrendingUp, Settings, ChevronLeft, ChevronRight, LogOut, Crown, Zap, Shield, Crosshair, Menu, X, Tag, Target, Coins, Briefcase, MessageSquare, } from 'lucide-react' import { useState, useEffect } from 'react' import clsx from 'clsx' interface SidebarProps { collapsed?: boolean onCollapsedChange?: (collapsed: boolean) => void } export function Sidebar({ collapsed: controlledCollapsed, onCollapsedChange }: SidebarProps) { const pathname = usePathname() const { user, logout, subscription, domains } = useStore() const [internalCollapsed, setInternalCollapsed] = useState(false) const [mobileOpen, setMobileOpen] = useState(false) const collapsed = controlledCollapsed ?? internalCollapsed const setCollapsed = onCollapsedChange ?? setInternalCollapsed useEffect(() => { const saved = localStorage.getItem('sidebar-collapsed') if (saved) { setCollapsed(saved === 'true') } }, []) useEffect(() => { setMobileOpen(false) }, [pathname]) const toggleCollapsed = () => { const newState = !collapsed setCollapsed(newState) localStorage.setItem('sidebar-collapsed', String(newState)) } const tierName = subscription?.tier_name || subscription?.tier || 'Scout' const TierIcon = tierName === 'Tycoon' ? Crown : tierName === 'Trader' ? TrendingUp : Zap const availableCount = domains?.filter(d => d.is_available).length || 0 const isTycoon = tierName.toLowerCase() === 'tycoon' // SECTION 1: Discover - Hunt is the main discovery hub const discoverItems = [ { href: '/terminal/hunt', label: 'HUNT', icon: Crosshair, badge: null, }, { href: '/terminal/intel', label: 'INTEL', icon: TrendingUp, badge: null, }, ] // SECTION 2: Manage - Your own assets and tools const manageItems: Array<{ href: string label: string icon: any badge: number | null tycoonOnly?: boolean }> = [ { href: '/terminal/watchlist', label: 'WATCHLIST', icon: Eye, badge: availableCount || null, }, { href: '/terminal/portfolio', label: 'PORTFOLIO', icon: Briefcase, badge: null, }, { href: '/terminal/inbox', label: 'INBOX', icon: MessageSquare, badge: null, }, { href: '/terminal/sniper', label: 'SNIPER', icon: Target, badge: null, }, ] // SECTION 3: Monetize - Passive income + For Sale const monetizeItems: Array<{ href: string label: string icon: any badge: number | null isNew?: boolean }> = [ { href: '/terminal/yield', label: 'YIELD', icon: Coins, badge: null, isNew: true, }, { href: '/terminal/listing', label: 'FOR SALE', icon: Tag, badge: null, }, ] const bottomItems = [ { href: '/terminal/settings', label: 'Settings', icon: Settings }, ] const isActive = (href: string) => { if (href === '/terminal/hunt') return pathname === '/terminal/hunt' || pathname === '/terminal' || pathname === '/terminal/dashboard' return pathname.startsWith(href) } const SidebarContent = () => ( <> {/* Logo Section */}
pounce
{!collapsed && (
POUNCE Terminal
)}
{/* Main Navigation */} {/* Bottom Section */}
{/* Admin Link */} {user?.is_admin && ( setMobileOpen(false)} className="group flex items-center gap-3 px-3 py-2 text-amber-500/60 hover:text-amber-400 transition-all" title={collapsed ? "Admin Panel" : undefined} > {!collapsed && Admin} )} {/* Settings */} {bottomItems.map((item) => ( setMobileOpen(false)} className={clsx( "group flex items-center gap-3 px-3 py-2 transition-all", isActive(item.href) ? "text-white" : "text-white/40 hover:text-white" )} title={collapsed ? item.label : undefined} > {!collapsed && {item.label}} ))} {/* User Card */}
{collapsed ? (
) : ( <>

{user?.name || user?.email?.split('@')[0]}

{tierName}
Usage {subscription?.domains_used || 0}/{subscription?.domain_limit || 5}
{tierName === 'Scout' && ( Upgrade )} )}
{/* Logout */}
{/* Collapse Toggle */} ) return ( <> {/* Mobile Menu Button */} {/* Mobile Overlay */} {mobileOpen && (
setMobileOpen(false)} /> )} {/* Mobile Sidebar */} {/* Desktop Sidebar */} ) }