1- import { useState } from "react" ;
1+ import { useEffect , useState } from "react" ;
22import Image from "next/image" ;
33import { CardDetailType } from "@/types/cards" ;
44import { ColumnNameTag } from "../modalInput/chips/ColumnNameTag" ;
@@ -14,17 +14,20 @@ interface CardDetailProps {
1414
1515export default function CardDetail ( { card, columnName } : CardDetailProps ) {
1616 const [ isImageModalOpen , setIsImageModalOpen ] = useState ( false ) ;
17+ const [ currentCard , setCurrentCard ] = useState < CardDetailType > ( card ) ;
18+
19+ useEffect ( ( ) => {
20+ setCurrentCard ( card ) ;
21+ } , [ card ] ) ;
1722
1823 return (
1924 < div className = "flex flex-col gap-5 w-full" >
25+ { /* 상태 + 태그 */ }
2026 < div className = "flex flex-wrap items-center gap-5" >
21- { /* 칼럼 이름 태그 */ }
2227 < ColumnNameTag label = { columnName } />
23- { /* 구분선 */ }
2428 < div className = "w-[1px] h-[20px] bg-[var(--color-gray3)]" />
25- { /* 카드 태그 */ }
2629 < div className = "flex flex-wrap gap-[6px]" >
27- { card . tags . map ( ( tag , idx ) => {
30+ { currentCard . tags . map ( ( tag , idx ) => {
2831 const { textColor, bgColor } = getTagColor ( idx ) ;
2932 return (
3033 < ColorTagChip key = { idx } className = { `${ textColor } ${ bgColor } ` } >
@@ -35,39 +38,52 @@ export default function CardDetail({ card, columnName }: CardDetailProps) {
3538 </ div >
3639 </ div >
3740
38- { /* 내용 */ }
39- < p
40- className = "
41- text-black font-normal sm:text-[16px] text-[14px] overflow-auto pr-1
42- w-full lg:max-w-[445px] sm:max-w-[420px] max-w-[295px]
43- min-h-0 sm:max-h-[100px] max-h-[80px]
44- whitespace-pre-wrap word-break break-words
45- "
46- >
47- { card . description }
41+ { /* 설명 */ }
42+ < p className = "text-black font-normal sm:text-[16px] text-[14px] overflow-auto pr-1 w-full lg:max-w-[445px] sm:max-w-[420px] max-w-[295px] min-h-0 sm:max-h-[100px] max-h-[80px] whitespace-pre-wrap word-break break-words" >
43+ { currentCard . description }
4844 </ p >
4945
46+ { /* 담당자 */ }
47+ < div className = "flex items-center gap-2 text-sm text-[var(--color-gray1)]" >
48+ < span className = "font-medium" > 담당자:</ span >
49+ { currentCard . assignee . profileImageUrl ? (
50+ < Image
51+ src = { currentCard . assignee . profileImageUrl }
52+ alt = "프로필 이미지"
53+ width = { 24 }
54+ height = { 24 }
55+ className = "w-6 h-6 rounded-full object-cover"
56+ />
57+ ) : (
58+ < div className = "w-6 h-6 flex items-center justify-center bg-[#A3C4A2] text-white font-medium rounded-full text-xs" >
59+ { currentCard . assignee . nickname [ 0 ] }
60+ </ div >
61+ ) }
62+ < span > { currentCard . assignee . nickname } </ span >
63+ </ div >
64+
5065 { /* 이미지 */ }
51- { card . imageUrl && (
66+ { currentCard . imageUrl && (
5267 < div
5368 className = "md:w-[420px] lg:w-[445px] cursor-pointer"
5469 onClick = { ( ) => setIsImageModalOpen ( true ) }
5570 >
5671 < Image
57- src = { card . imageUrl }
72+ src = { currentCard . imageUrl }
5873 alt = "카드 이미지"
5974 width = { 290 }
6075 height = { 168 }
6176 className = "rounded-lg object-cover
62- lg:w-[445px] md:w-[420px]
63- lg:h-[280px] md:h-[240px]
64- sm:max-h-none max-h-[180px]"
77+ lg:w-[445px] md:w-[420px]
78+ lg:h-[280px] md:h-[240px]
79+ sm:max-h-none max-h-[180px]"
6580 />
6681 </ div >
6782 ) }
68- { isImageModalOpen && (
83+
84+ { isImageModalOpen && currentCard . imageUrl && (
6985 < PopupImageModal
70- imageUrl = { card . imageUrl ! }
86+ imageUrl = { currentCard . imageUrl }
7187 onClose = { ( ) => setIsImageModalOpen ( false ) }
7288 />
7389 ) }
0 commit comments