diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 9985be5..d35d1ec 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -9,6 +9,7 @@ import SystemLogsPage from './pages/SystemLogsPage'; import LogMonitoringPage from './pages/LogMonitoringPage'; import ErrorBoundary from './components/ErrorBoundary'; import errorLogger from './utils/errorLogger'; +import api from './api'; import './App.css'; function App() { @@ -19,6 +20,48 @@ function App() { const [pageParams, setPageParams] = useState({}); const [selectedProject, setSelectedProject] = useState(null); const [showUserMenu, setShowUserMenu] = useState(false); + const [projects, setProjects] = useState([]); + const [editingProject, setEditingProject] = useState(null); + const [editedProjectName, setEditedProjectName] = useState(''); + + // 프로젝트 목록 로드 + const loadProjects = async () => { + try { + const response = await api.get('/projects'); + if (response.data && response.data.projects) { + setProjects(response.data.projects); + } + } catch (error) { + console.error('프로젝트 목록 로드 실패:', error); + } + }; + + // 프로젝트 이름 수정 + const updateProjectName = async (projectId) => { + try { + const response = await api.patch(`/dashboard/projects/${projectId}?job_name=${encodeURIComponent(editedProjectName)}`); + + if (response.data.success) { + // 프로젝트 목록 갱신 + await loadProjects(); + + // 선택된 프로젝트 업데이트 + if (selectedProject && selectedProject.id === projectId) { + setSelectedProject({ + ...selectedProject, + project_name: editedProjectName + }); + } + + setEditingProject(null); + setEditedProjectName(''); + alert('프로젝트 이름이 수정되었습니다.'); + } + } catch (error) { + console.error('프로젝트 이름 수정 실패:', error); + alert('프로젝트 이름 수정에 실패했습니다.'); + } + }; useEffect(() => { // 저장된 토큰 확인 @@ -28,6 +71,7 @@ function App() { if (token && userData) { setIsAuthenticated(true); setUser(JSON.parse(userData)); + loadProjects(); // 프로젝트 목록 로드 } setIsLoading(false); @@ -313,15 +357,43 @@ function App() { {/* 프로젝트 선택 */}
-

- 📁 프로젝트 선택 -

+
+

+ 📁 프로젝트 선택 +

+ {selectedProject && ( + + )} +
+ + + {/* 프로젝트 이름 편집 폼 */} + {editingProject && ( +
+
+ 프로젝트 이름 수정: {editingProject.official_project_code} +
+
+ setEditedProjectName(e.target.value)} + onKeyPress={(e) => { + if (e.key === 'Enter') updateProjectName(editingProject.id); + }} + placeholder="새 프로젝트 이름" + autoFocus + style={{ + flex: 1, + padding: '10px 12px', + border: '2px solid #3b82f6', + borderRadius: '6px', + fontSize: '14px' + }} + /> + + +
+
+ )}
{/* 핵심 기능 */}