diff --git a/Project/frontend/src/pages/PatchList.tsx b/Project/frontend/src/pages/PatchList.tsx index c8828fc..302728c 100644 --- a/Project/frontend/src/pages/PatchList.tsx +++ b/Project/frontend/src/pages/PatchList.tsx @@ -1,5 +1,5 @@ import { useState, useEffect } from 'react'; -import { FileText, Search, RefreshCw, Calendar, User } from 'lucide-react'; +import { FileText, Search, RefreshCw, Calendar, User, Edit3 } from 'lucide-react'; import { comms } from '@/communication'; import { BoardItem } from '@/types'; @@ -9,11 +9,28 @@ export function PatchList() { const [searchKey, setSearchKey] = useState(''); const [selectedItem, setSelectedItem] = useState(null); const [showModal, setShowModal] = useState(false); + const [showEditModal, setShowEditModal] = useState(false); + const [editFormData, setEditFormData] = useState(null); + const [userLevel, setUserLevel] = useState(0); + const [userId, setUserId] = useState(''); useEffect(() => { + loadUserInfo(); loadData(); }, []); + const loadUserInfo = async () => { + try { + const response = await comms.checkLoginStatus(); + if (response.Success && response.User) { + setUserLevel(response.User.Level); + setUserId(response.User.Id); + } + } catch (error) { + console.error('사용자 정보 로드 오류:', error); + } + }; + const loadData = async () => { setLoading(true); try { @@ -43,7 +60,14 @@ export function PatchList() { const response = await comms.getBoardDetail(item.idx); if (response.Success && response.Data) { setSelectedItem(response.Data); - setShowModal(true); + + // 개발자(레벨 >= 9) 또는 사번 395552이면 바로 편집 모드 + if (userLevel >= 9 || userId === '395552') { + setEditFormData(response.Data); + setShowEditModal(true); + } else { + setShowModal(true); + } } } catch (error) { console.error('상세 조회 오류:', error); @@ -51,6 +75,27 @@ export function PatchList() { } }; + const handleEditClick = () => { + if (selectedItem) { + setEditFormData(selectedItem); + setShowModal(false); + setShowEditModal(true); + } + }; + + const handleEditSave = async () => { + if (!editFormData) return; + + try { + // TODO: Board_Edit API 구현 필요 + alert('게시판 수정 API가 아직 구현되지 않았습니다.'); + console.log('수정할 데이터:', editFormData); + } catch (error) { + console.error('저장 오류:', error); + alert('저장 중 오류가 발생했습니다.'); + } + }; + const formatDate = (dateStr: string | null) => { if (!dateStr) return '-'; try { @@ -203,7 +248,16 @@ export function PatchList() { -
+
+ {(userLevel >= 9 || userId === '395552') && ( + + )}
)} + + {/* 편집 모달 */} + {showEditModal && editFormData && ( +
+
+
+

+ + 패치내역 편집 +

+ +
+ +
+
+ + setEditFormData({ ...editFormData, header: e.target.value })} + className="w-full h-10 bg-white/10 border border-white/30 rounded-lg px-3 text-white placeholder-white/50 focus:outline-none focus:ring-2 focus:ring-primary-400" + placeholder="예: v2.0.0" + /> +
+ +
+ + setEditFormData({ ...editFormData, cate: e.target.value })} + className="w-full h-10 bg-white/10 border border-white/30 rounded-lg px-3 text-white placeholder-white/50 focus:outline-none focus:ring-2 focus:ring-primary-400" + placeholder="예: 기능개선" + /> +
+ +
+ + setEditFormData({ ...editFormData, title: e.target.value })} + className="w-full h-10 bg-white/10 border border-white/30 rounded-lg px-3 text-white placeholder-white/50 focus:outline-none focus:ring-2 focus:ring-primary-400" + placeholder="패치 제목" + /> +
+ +
+ +