import React, { useState, useEffect } from 'react'; const DashboardPage = ({ user, projects, pendingSignupCount, navigateToPage, loadProjects, createProject, updateProjectName, deleteProject, editingProject, setEditingProject, editedProjectName, setEditedProjectName, showCreateProject, setShowCreateProject, newProjectCode, setNewProjectCode, newProjectName, setNewProjectName, newClientName, setNewClientName, inactiveProjects, setInactiveProjects, }) => { const [selectedProject, setSelectedProject] = useState(null); const [showProjectDropdown, setShowProjectDropdown] = useState(false); // 프로젝트 생성 모달 닫기 const handleCloseCreateProject = () => { setShowCreateProject(false); setNewProjectCode(''); setNewProjectName(''); setNewClientName(''); }; // 프로젝트 선택 처리 const handleProjectSelect = (project) => { setSelectedProject(project); setShowProjectDropdown(false); }; // 프로젝트 비활성화 const handleDeactivateProject = (project) => { const projectId = project.job_no || project.official_project_code || project.id; const projectName = project.job_name || project.project_name || projectId; console.log('🔍 비활성화 요청:', { project, projectId, projectName }); if (window.confirm(`"${projectName}" 프로젝트를 비활성화하시겠습니까?`)) { setInactiveProjects(prev => { const newSet = new Set([...prev, projectId]); console.log('📦 비활성화 프로젝트 업데이트:', { prev: Array.from(prev), new: Array.from(newSet) }); return newSet; }); const selectedProjectId = selectedProject?.job_no || selectedProject?.official_project_code || selectedProject?.id; if (selectedProjectId === projectId) { setSelectedProject(null); } setShowProjectDropdown(false); } }; // 프로젝트 활성화 const handleActivateProject = (project) => { setInactiveProjects(prev => { const newSet = new Set(prev); newSet.delete(project.job_no); return newSet; }); }; // 프로젝트 삭제 (드롭다운용) const handleDeleteProjectFromDropdown = (project, e) => { e.stopPropagation(); if (window.confirm(`"${project.job_name || project.job_no}" 프로젝트를 완전히 삭제하시겠습니까?`)) { deleteProject(project.job_no); setShowProjectDropdown(false); } }; // 컴포넌트 마운트 시 프로젝트 로드 useEffect(() => { loadProjects(); }, []); return (
{/* 대시보드 헤더 */}

Dashboard

TK-MP BOM Management System v2.0 - Project Selection Interface

{/* 프로젝트 선택 섹션 */}

Project Selection

Choose a project to access BOM and purchase management

{/* 프로젝트 드롭다운 */}
{/* 드롭다운 메뉴 */} {showProjectDropdown && (
{projects.length === 0 ? (
No projects available. Create a new one!
) : ( projects .filter(project => { const projectId = project.job_no || project.official_project_code || project.id; return !inactiveProjects.has(projectId); }) .map((project) => (
handleProjectSelect(project)} style={{ padding: '16px 20px', cursor: 'pointer', flex: 1 }} onMouseEnter={(e) => e.target.closest('div').style.background = '#f8fafc'} onMouseLeave={(e) => e.target.closest('div').style.background = 'white'} >
{project.job_name || project.job_no}
Code: {project.job_no} | Client: {project.client_name || 'N/A'}
{/* 프로젝트 관리 버튼들 */}
)) )}
)}
{/* 프로젝트가 선택된 경우 - 프로젝트 관련 메뉴 */} {selectedProject && (

Project Management

{/* 통합 BOM 관리 */}
navigateToPage('unified-bom', { selectedProject })} style={{ background: 'white', borderRadius: '16px', padding: '32px', boxShadow: '0 8px 20px rgba(0, 0, 0, 0.08)', border: '1px solid #e2e8f0', cursor: 'pointer', transition: 'all 0.3s ease', textAlign: 'center' }} onMouseEnter={(e) => { e.currentTarget.style.transform = 'translateY(-5px)'; e.currentTarget.style.boxShadow = '0 12px 30px rgba(0, 0, 0, 0.15)'; }} onMouseLeave={(e) => { e.currentTarget.style.transform = 'translateY(0)'; e.currentTarget.style.boxShadow = '0 8px 20px rgba(0, 0, 0, 0.08)'; }} >
BOM

BOM Management

Upload, manage revisions, and classify materials in one unified workspace

{/* 기능 미리보기 */}
📤 Upload
📊 Revisions
📋 Materials
{/* 구매신청 관리 */}
navigateToPage('purchase-request', { selectedProject })} style={{ background: 'white', borderRadius: '16px', padding: '32px', boxShadow: '0 8px 20px rgba(0, 0, 0, 0.08)', border: '1px solid #e2e8f0', cursor: 'pointer', transition: 'all 0.3s ease', textAlign: 'center' }} onMouseEnter={(e) => { e.currentTarget.style.transform = 'translateY(-5px)'; e.currentTarget.style.boxShadow = '0 12px 30px rgba(0, 0, 0, 0.15)'; }} onMouseLeave={(e) => { e.currentTarget.style.transform = 'translateY(0)'; e.currentTarget.style.boxShadow = '0 8px 20px rgba(0, 0, 0, 0.08)'; }} >
REQ

Purchase Request Management

Manage purchase requests and export materials to Excel for procurement.

)} {/* 관리자 메뉴 (Admin 이상만 표시) */} {user?.role === 'admin' && (

System Administration

{/* 사용자 관리 */}
navigateToPage('user-management')} style={{ background: 'white', borderRadius: '16px', padding: '24px', boxShadow: '0 8px 20px rgba(0, 0, 0, 0.08)', border: '1px solid #e2e8f0', cursor: 'pointer', transition: 'all 0.3s ease', textAlign: 'center' }} onMouseEnter={(e) => { e.currentTarget.style.transform = 'translateY(-3px)'; e.currentTarget.style.boxShadow = '0 12px 25px rgba(0, 0, 0, 0.12)'; }} onMouseLeave={(e) => { e.currentTarget.style.transform = 'translateY(0)'; e.currentTarget.style.boxShadow = '0 8px 20px rgba(0, 0, 0, 0.08)'; }} >
USER

User Management

Manage user accounts and permissions

{pendingSignupCount > 0 && (
{pendingSignupCount} pending
)}
{/* 시스템 설정 */}
navigateToPage('system-settings')} style={{ background: 'white', borderRadius: '16px', padding: '24px', boxShadow: '0 8px 20px rgba(0, 0, 0, 0.08)', border: '1px solid #e2e8f0', cursor: 'pointer', transition: 'all 0.3s ease', textAlign: 'center' }} onMouseEnter={(e) => { e.currentTarget.style.transform = 'translateY(-3px)'; e.currentTarget.style.boxShadow = '0 12px 25px rgba(0, 0, 0, 0.12)'; }} onMouseLeave={(e) => { e.currentTarget.style.transform = 'translateY(0)'; e.currentTarget.style.boxShadow = '0 8px 20px rgba(0, 0, 0, 0.08)'; }} >
SYS

System Settings

Configure system preferences and settings

{/* 시스템 로그 */}
navigateToPage('system-logs')} style={{ background: 'white', borderRadius: '16px', padding: '24px', boxShadow: '0 8px 20px rgba(0, 0, 0, 0.08)', border: '1px solid #e2e8f0', cursor: 'pointer', transition: 'all 0.3s ease', textAlign: 'center' }} onMouseEnter={(e) => { e.currentTarget.style.transform = 'translateY(-3px)'; e.currentTarget.style.boxShadow = '0 12px 25px rgba(0, 0, 0, 0.12)'; }} onMouseLeave={(e) => { e.currentTarget.style.transform = 'translateY(0)'; e.currentTarget.style.boxShadow = '0 8px 20px rgba(0, 0, 0, 0.08)'; }} >
LOG

System Logs

View system activity and error logs

{/* 로그 모니터링 */}
navigateToPage('log-monitoring')} style={{ background: 'white', borderRadius: '16px', padding: '24px', boxShadow: '0 8px 20px rgba(0, 0, 0, 0.08)', border: '1px solid #e2e8f0', cursor: 'pointer', transition: 'all 0.3s ease', textAlign: 'center' }} onMouseEnter={(e) => { e.currentTarget.style.transform = 'translateY(-3px)'; e.currentTarget.style.boxShadow = '0 12px 25px rgba(0, 0, 0, 0.12)'; }} onMouseLeave={(e) => { e.currentTarget.style.transform = 'translateY(0)'; e.currentTarget.style.boxShadow = '0 8px 20px rgba(0, 0, 0, 0.08)'; }} >
MON

Log Monitoring

Real-time system monitoring and alerts

)} {/* 시스템 현황 섹션 */}

System Overview

{/* 등록된 프로젝트 */}
{projects.length || 0}
Registered Projects
{/* 선택된 프로젝트 */}
{selectedProject ? '1' : '0'}
Selected Project
{/* 현재 권한 */}
{user?.role === 'admin' ? 'Admin' : 'User'}
Current Role
{/* 시스템 상태 */}
Active
System Status
{/* 프로젝트 생성 모달 */} {showCreateProject && (

Create New Project

setNewProjectCode(e.target.value)} style={{ width: '100%', padding: '12px', borderRadius: '8px', border: '1px solid #cbd5e1', fontSize: '16px', boxSizing: 'border-box' }} placeholder="e.g., J24-001" />
setNewProjectName(e.target.value)} style={{ width: '100%', padding: '12px', borderRadius: '8px', border: '1px solid #cbd5e1', fontSize: '16px', boxSizing: 'border-box' }} placeholder="e.g., Ulsan SK Energy Expansion" />
setNewClientName(e.target.value)} style={{ width: '100%', padding: '12px', borderRadius: '8px', border: '1px solid #cbd5e1', fontSize: '16px', boxSizing: 'border-box' }} placeholder="e.g., Samsung Engineering" />
)}
); }; export default DashboardPage;