'use client'; import { useState, useEffect } from 'react'; import Link from 'next/link'; import { usePathname } from 'next/navigation'; import { useAuth } from '@/lib/auth'; import { LayoutDashboard, TrendingUp, KeyRound, Bot, Settings, User, LogOut, Menu, } from 'lucide-react'; import { cn } from '@/lib/cn'; const NAV = [ { href: '/', label: '대시보드', icon: LayoutDashboard }, { href: '/trades', label: '트레이드 이력', icon: TrendingUp }, { href: '/exchange', label: '거래소 API', icon: KeyRound }, { href: '/automation', label: '자동매매', icon: Bot }, { href: '/settings', label: '시스템 설정', icon: Settings }, { href: '/profile', label: '내 정보', icon: User }, ]; const Logo = ({ mini = false }: { mini?: boolean }) => ( {!mini && ( <> JUNGGOMOA 트레이딩 시스템 )} ); export default function Sidebar() { const pathname = usePathname(); const { user, logout } = useAuth(); const [mini, setMini] = useState(false); const [mobileOpen, setMobileOpen] = useState(false); useEffect(() => { setMobileOpen(false); }, [pathname]); const initial = (user?.username?.[0] || '?').toUpperCase(); const w = mini ? 'w-[68px]' : 'w-[260px]'; return ( <> {/* 모바일 햄버거 (사이드바 밖) */} {/* 모바일 오버레이 */} {mobileOpen && (
setMobileOpen(false)} /> )} {/* 사이드바 */} {/* 모바일 슬라이드 사이드바 */} ); } function SidebarInner({ mini, setMini, pathname, initial, username, role, logout }: any) { return ( <> {/* 헤더: 로고(좌) + 햄버거(우) */}
{!mini && } {mini && } {!mini && ( )}
{mini && ( )} {/* 메뉴 */} {/* 푸터: 사용자 + 로그아웃 */}
{!mini ? ( <>
{initial}
{username || 'guest'}
{role}
) : ( )}
); }