// components/project/ProjectSidebar.tsx 'use client'; import { useState, useEffect } from 'react'; import { useRouter, usePathname } from 'next/navigation'; import { Home, FolderOpen, Users, Settings, Plus, ChevronLeft, ChevronRight, Search, Crown, Shield, Eye, Clock, Star, LogOut } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { ScrollArea } from '@/components/ui/scroll-area'; import { Input } from '@/components/ui/input'; import { Separator } from '@/components/ui/separator'; import { Badge } from '@/components/ui/badge'; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from '@/components/ui/tooltip'; import { cn } from '@/lib/utils'; import { useSession, signOut } from 'next-auth/react'; interface RecentProject { id: string; name: string; role: string; lastAccessed: string; } export function ProjectSidebar() { const [collapsed, setCollapsed] = useState(false); const [recentProjects, setRecentProjects] = useState([]); const [favoriteProjects, setFavoriteProjects] = useState([]); const router = useRouter(); const pathname = usePathname(); const { data: session } = useSession(); const isInternalUser = session?.user?.domain !== 'partners'; useEffect(() => { // 최근 프로젝트 로드 const stored = localStorage.getItem('recentProjects'); if (stored) { setRecentProjects(JSON.parse(stored)); } // 즐겨찾기 프로젝트 로드 const favorites = localStorage.getItem('favoriteProjects'); if (favorites) { setFavoriteProjects(JSON.parse(favorites)); } }, [pathname]); const menuItems = [ { label: '홈', icon: Home, href: '/projects', active: pathname === '/projects', }, { label: '모든 프로젝트', icon: FolderOpen, href: '/projects', active: pathname === '/projects', }, ...(isInternalUser ? [{ label: '팀 관리', icon: Users, href: '/projects/team', active: pathname === '/projects/team', }] : []), { label: '설정', icon: Settings, href: '/projects/settings', active: pathname === '/projects/settings', }, ]; const roleIcons = { owner: { icon: Crown, color: 'text-yellow-500' }, admin: { icon: Shield, color: 'text-blue-500' }, viewer: { icon: Eye, color: 'text-gray-500' }, }; return (
{/* 헤더 */}
{!collapsed && (

파일 매니저

{session?.user?.name}

)}
{/* 검색 */} {!collapsed && (
)} {/* 메인 메뉴 */}
{!collapsed && (

메뉴

)} {menuItems.map((item) => ( {collapsed && ( {item.label} )} ))}
{/* 빠른 액세스 */} {!collapsed && (

빠른 액세스

{/* 즐겨찾기 프로젝트 */} {favoriteProjects.length > 0 && (
{favoriteProjects.slice(0, 3).map((projectId) => ( ))}
)} {/* 최근 프로젝트 */}

최근 프로젝트

{recentProjects.slice(0, 5).map((project) => { const RoleIcon = roleIcons[project.role as keyof typeof roleIcons]; return ( ); })}
)} {collapsed && (
새 프로젝트 {recentProjects.slice(0, 3).map((project) => { const RoleIcon = roleIcons[project.role as keyof typeof roleIcons]; return ( {project.name} ); })}
)}
{/* 하단 사용자 정보 */}
{!collapsed ? (
{session?.user?.name?.charAt(0).toUpperCase()}

{session?.user?.name}

{isInternalUser ? '내부' : '외부'}
) : ( 로그아웃 )}
); }