"use client"; import { useState } from "react"; import { Button } from "@/components/ui/button"; import { Card, CardContent } from "@/components/ui/card"; import { Home, FileText, Users, Settings, Package, BarChart3, LogOut, Menu, X, ChevronDown, ChevronRight, } from "lucide-react"; import { useAuth } from "@/hooks/useAuth"; interface UserInfo { userId: string; userName: string; deptName: string; email: string; } interface MenuItem { id: string; title: string; icon: any; children?: MenuItem[]; } const menuItems: MenuItem[] = [ { id: "dashboard", title: "대시보드", icon: Home, }, { id: "project", title: "프로젝트 관리", icon: FileText, children: [ { id: "project-list", title: "프로젝트 목록", icon: FileText }, { id: "project-concept", title: "프로젝트 컨셉", icon: FileText }, { id: "project-planning", title: "프로젝트 기획", icon: FileText }, ], }, { id: "part", title: "부품 관리", icon: Package, children: [ { id: "part-list", title: "부품 목록", icon: Package }, { id: "part-bom", title: "BOM 관리", icon: Package }, { id: "part-inventory", title: "재고 관리", icon: Package }, ], }, { id: "user", title: "사용자 관리", icon: Users, children: [ { id: "user-list", title: "사용자 목록", icon: Users }, { id: "user-auth", title: "권한 관리", icon: Users }, ], }, { id: "report", title: "보고서", icon: BarChart3, children: [ { id: "report-project", title: "프로젝트 보고서", icon: BarChart3 }, { id: "report-cost", title: "비용 보고서", icon: BarChart3 }, ], }, { id: "settings", title: "시스템 설정", icon: Settings, children: [ { id: "settings-system", title: "시스템 설정", icon: Settings }, { id: "settings-common", title: "공통 코드", icon: Settings }, ], }, ]; export default function DashboardPage() { const { user, logout } = useAuth(); const [sidebarOpen, setSidebarOpen] = useState(true); const [expandedMenus, setExpandedMenus] = useState>(new Set(["dashboard"])); const [selectedMenu, setSelectedMenu] = useState("dashboard"); const [currentContent, setCurrentContent] = useState("dashboard"); const handleLogout = async () => { await logout(); }; const toggleMenu = (menuId: string) => { const newExpanded = new Set(expandedMenus); if (newExpanded.has(menuId)) { newExpanded.delete(menuId); } else { newExpanded.add(menuId); } setExpandedMenus(newExpanded); }; const handleMenuClick = (menuId: string) => { setSelectedMenu(menuId); setCurrentContent(menuId); }; const renderContent = () => { switch (currentContent) { case "dashboard": return (

대시보드

전체 프로젝트

24

등록된 부품

1,247

활성 사용자

89

진행중인 작업

12

최근 활동

새로운 프로젝트 '제품 A' 생성됨 2시간 전
부품 'PCB-001' 승인 완료 4시간 전
사용자 '김개발' 권한 변경 1일 전
); default: return (

{menuItems.find((item) => item.id === currentContent)?.title || menuItems.flatMap((item) => item.children || []).find((child) => child.id === currentContent)?.title || "페이지를 찾을 수 없습니다"}

{currentContent} 페이지 컨텐츠가 여기에 표시됩니다.

각 메뉴에 맞는 컴포넌트를 개발하여 연결할 수 있습니다.

); } }; const renderMenuItem = (item: MenuItem, level: number = 0) => { const isExpanded = expandedMenus.has(item.id); const isSelected = selectedMenu === item.id; const hasChildren = item.children && item.children.length > 0; return (
0 ? "ml-6" : ""}`} onClick={() => { if (hasChildren) { toggleMenu(item.id); } else { handleMenuClick(item.id); } }} > {item.title} {hasChildren && (isExpanded ? : )}
{hasChildren && isExpanded && (
{item.children?.map((child) => renderMenuItem(child, level + 1))}
)}
); }; return (
{/* 헤더 */}

PLM 시스템

{/* 사이드바 */} {/* 메인 컨텐츠 */}
{renderContent()}
); }