11import { useState } from "react" ;
2- import { MoreVertical , X } from "lucide-react" ; // lucide 아이콘
2+ import { MoreVertical , X } from "lucide-react" ;
33import CardDetail from "./CardDetail" ;
44import CommentList from "./CommentList" ;
55import CardInput from "@/components/modalInput/CardInput" ;
66import { useMutation , useQueryClient } from "@tanstack/react-query" ;
77import { createComment } from "@/api/comment" ;
88import { deleteCard } from "@/api/card" ;
99import type { CardType } from "@/types/cards" ;
10+ import TaskModal from "@/components/modalInput/TaskModal" ; // 경로는 실제 위치에 맞게 조정하세요
1011
1112interface CardDetailModalProps {
1213 card : CardType ;
1314 currentUserId : number ;
1415 teamId : string ;
1516 dashboardId : number ;
1617 onClose : ( ) => void ;
17- onEditClick ?: ( ) => void ; // 수정 모달 열기용 (선택)
1818}
1919
2020export default function CardDetailPage ( {
@@ -23,16 +23,16 @@ export default function CardDetailPage({
2323 teamId,
2424 dashboardId,
2525 onClose,
26- onEditClick,
2726} : CardDetailModalProps ) {
27+ const [ cardData , setCardData ] = useState < CardType > ( card ) ;
2828 const [ commentText , setCommentText ] = useState ( "" ) ;
2929 const [ showMenu , setShowMenu ] = useState ( false ) ;
30+ const [ isEditModalOpen , setIsEditModalOpen ] = useState ( false ) ;
3031 const queryClient = useQueryClient ( ) ;
3132
3233 const { mutate : createCommentMutate } = useMutation ( {
3334 mutationFn : createComment ,
3435 onSuccess : ( ) => {
35- console . log ( "댓글 등록 성공!" ) ;
3636 setCommentText ( "" ) ;
3737 queryClient . invalidateQueries ( { queryKey : [ "comments" , card . id ] } ) ;
3838 } ,
@@ -42,7 +42,7 @@ export default function CardDetailPage({
4242 mutationFn : ( ) => deleteCard ( teamId , card . id ) ,
4343 onSuccess : ( ) => {
4444 queryClient . invalidateQueries ( { queryKey : [ "cards" ] } ) ;
45- onClose ( ) ; // 모달 닫기
45+ onClose ( ) ;
4646 } ,
4747 } ) ;
4848
@@ -57,64 +57,97 @@ export default function CardDetailPage({
5757 } ;
5858
5959 return (
60- < div className = "fixed inset-0 bg-black/30 z-50 flex items-center justify-center" >
61- < div className = "relative bg-white rounded-lg shadow-lg w-[730px] h-[763px] flex flex-col" >
62- { /* 오른쪽 상단 메뉴 */ }
63- < div className = "absolute top-2 right-6 w-[50px] h-[50px] z-30 flex items-center gap-2" >
64- < div className = "relative" >
65- < button onClick = { ( ) => setShowMenu ( ( prev ) => ! prev ) } >
66- < MoreVertical className = "w-8 h-8 text-gray-500 hover:text-black" />
60+ < >
61+ < div className = "fixed inset-0 bg-black/30 z-50 flex items-center justify-center" >
62+ < div className = "relative bg-white rounded-lg shadow-lg w-[730px] h-[763px] flex flex-col" >
63+ { /* 오른쪽 상단 메뉴 */ }
64+ < div className = "absolute top-2 right-6 w-[50px] h-[50px] z-30 flex items-center gap-2" >
65+ < div className = "relative" >
66+ < button onClick = { ( ) => setShowMenu ( ( prev ) => ! prev ) } >
67+ < MoreVertical className = "w-8 h-8 text-gray-500 hover:text-black" />
68+ </ button >
69+ { showMenu && (
70+ < div className = "absolute right-0 mt-2 w-24 bg-white border rounded shadow z-40" >
71+ < button
72+ className = "block w-full px-3 py-2 text-sm text-violet-600 hover:bg-gray-100"
73+ onClick = { ( ) => {
74+ setIsEditModalOpen ( true ) ;
75+ setShowMenu ( false ) ;
76+ } }
77+ >
78+ 수정하기
79+ </ button >
80+ < button
81+ className = "block w-full px-3 py-2 text-sm text-red-500 hover:bg-gray-100"
82+ onClick = { ( ) => deleteCardMutate ( ) }
83+ >
84+ 삭제하기
85+ </ button >
86+ </ div >
87+ ) }
88+ </ div >
89+ < button onClick = { onClose } >
90+ < X className = "w-8 h-8 text-gray-500 hover:text-black" />
6791 </ button >
68- { showMenu && (
69- < div className = "absolute right-0 mt-2 w-24 bg-white border rounded shadow z-40" >
70- < button
71- className = "block w-full px-3 py-2 text-sm text-violet-600 hover:bg-gray-100"
72- onClick = { ( ) => {
73- onEditClick ?.( ) ;
74- setShowMenu ( false ) ;
75- } }
76- >
77- 수정하기
78- </ button >
79- < button
80- className = "block w-full px-3 py-2 text-sm text-red-500 hover:bg-gray-100"
81- onClick = { ( ) => deleteCardMutate ( ) }
82- >
83- 삭제하기
84- </ button >
85- </ div >
86- ) }
8792 </ div >
88- < button onClick = { onClose } >
89- < X className = "w-8 h-8 text-gray-500 hover:text-black" />
90- </ button >
91- </ div >
9293
93- { /* 모달 내부 콘텐츠 */ }
94- < div className = "p-6 flex gap-6 overflow-y-auto" >
95- < CardDetail card = { card } columnName = { "" } />
96- </ div >
94+ { /* 모달 내부 콘텐츠 */ }
95+ < div className = "p-6 flex gap-6 overflow-y-auto" >
96+ < CardDetail card = { cardData } columnName = { "" } />
97+ </ div >
9798
98- { /* 댓글 입력창 */ }
99- < div className = "p-4" >
100- < CardInput
101- hasButton
102- small
103- value = { commentText }
104- onTextChange = { setCommentText }
105- onButtonClick = { handleCommentSubmit }
106- />
107- </ div >
99+ { /* 댓글 입력창 */ }
100+ < div className = "p-4" >
101+ < CardInput
102+ hasButton
103+ small
104+ value = { commentText }
105+ onTextChange = { setCommentText }
106+ onButtonClick = { handleCommentSubmit }
107+ />
108+ </ div >
108109
109- { /* 댓글 목록 */ }
110- < div className = "px-6 space-y-4 max-h-[200px] overflow-y-auto" >
111- < CommentList
112- cardId = { card . id }
113- currentUserId = { currentUserId }
114- teamId = { teamId }
115- />
110+ { /* 댓글 목록 */ }
111+ < div className = "px-6 space-y-4 max-h-[200px] overflow-y-auto" >
112+ < CommentList
113+ cardId = { card . id }
114+ currentUserId = { currentUserId }
115+ teamId = { "" }
116+ />
117+ </ div >
116118 </ div >
117119 </ div >
118- </ div >
120+
121+ { /* TaskModal 수정 모드 */ }
122+ { isEditModalOpen && (
123+ < TaskModal
124+ mode = "edit"
125+ onClose = { ( ) => setIsEditModalOpen ( false ) }
126+ onSubmit = { ( data ) => {
127+ setCardData ( ( prev ) => ( {
128+ ...prev ,
129+ status : data . status as "todo" | "in-progress" | "done" ,
130+ assignee : { ...prev . assignee , nickname : data . assignee } ,
131+ title : data . title ,
132+ description : data . description ,
133+ dueDate : data . deadline ,
134+ tags : data . tags ,
135+ imageUrl : data . image ?? "" ,
136+ } ) ) ;
137+ setIsEditModalOpen ( false ) ;
138+ } }
139+ initialData = { {
140+ status : cardData . status ,
141+ assignee : cardData . assignee . nickname ,
142+ title : cardData . title ,
143+ description : cardData . description ,
144+ deadline : cardData . dueDate ,
145+ tags : cardData . tags ,
146+ image : cardData . imageUrl ?? "" ,
147+ } }
148+ members = { [ { nickname : cardData . assignee . nickname } ] }
149+ />
150+ ) }
151+ </ >
119152 ) ;
120153}
0 commit comments