Skip to content

Commit 83b53f7

Browse files
authored
Merge pull request #155 from rover1523/mypage
[Fix] 수정하기 모달에서 수정후 데이터 전송버그 수정
2 parents 9a0308e + 703c493 commit 83b53f7

File tree

2 files changed

+30
-14
lines changed

2 files changed

+30
-14
lines changed

src/components/modalDashboard/CardDetail.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
import Image from "next/image";
33
import { CardDetailType } from "@/types/cards";
44
import { ProfileIcon } from "./profelicon";
5+
import ColorTagChip, {
6+
getTagColor,
7+
} from "@/components/modalInput/chips/ColorTagChip";
58

69
interface CardDetailProps {
710
card: CardDetailType;
@@ -47,23 +50,22 @@ export default function CardDetail({ card, columnName }: CardDetailProps) {
4750
</div>
4851
</div>
4952
</div>
50-
<div className="flex flex-wrap gap-2 mb-2">
53+
<div className="flex items-center gap-2 mb-2">
5154
<span
5255
className="rounded-full bg-violet-200 px-3 py-1 text-sm text-violet-800"
5356
title={`상태: ${columnName}`}
5457
>
5558
{columnName}
5659
</span>
5760
<span className="text-2xl font-extralight text-[#D9D9D9]">|</span>
58-
{card.tags.map((tag, idx) => (
59-
<span
60-
key={idx}
61-
className="rounded-full bg-gray-200 px-3 py-1 text-sm text-gray-700"
62-
>
63-
{}
64-
{tag}
65-
</span>
66-
))}
61+
{card.tags.map((tag, idx) => {
62+
const { textColor, bgColor } = getTagColor(idx);
63+
return (
64+
<ColorTagChip key={idx} className={`${textColor} ${bgColor}`}>
65+
{tag}
66+
</ColorTagChip>
67+
);
68+
})}
6769
</div>
6870
<p
6971
className="text-gray-700 p-2 break-words overflow-auto"

src/components/modalDashboard/CardDetailModal.tsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable react-hooks/rules-of-hooks */
12
import { useMemo, useRef, useState } from "react";
23
import { MoreVertical, X } from "lucide-react";
34
import CardDetail from "./CardDetail";
@@ -10,6 +11,7 @@ import type { CardDetailType } from "@/types/cards";
1011
import TaskModal from "@/components/modalInput/TaskModal";
1112
import { useClosePopup } from "@/hooks/useClosePopup";
1213
import { getColumn } from "@/api/columns";
14+
import { useRouter } from "next/router";
1315

1416
interface CardDetailModalProps {
1517
card: CardDetailType;
@@ -36,6 +38,7 @@ export default function CardDetailPage({
3638
const [isEditModalOpen, setIsEditModalOpen] = useState(false);
3739
const queryClient = useQueryClient();
3840
const popupRef = useRef(null);
41+
const router = useRouter();
3942
useClosePopup(popupRef, () => setShowMenu(false));
4043

4144
const { data: columns = [] } = useQuery<ColumnType[]>({
@@ -125,7 +128,13 @@ export default function CardDetailPage({
125128
)}
126129
</div>
127130

128-
<button onClick={onClose} title="닫기">
131+
<button
132+
onClick={() => {
133+
onClose();
134+
router.reload(); // ✅ Next.js 방식 리로드
135+
}}
136+
title="닫기"
137+
>
129138
<X className="w-7 h-7 flex items-center justify-center hover:cursor-pointer" />
130139
</button>
131140
</div>
@@ -170,19 +179,24 @@ export default function CardDetailPage({
170179
columnId={card.columnId} // ✅ 여기에 columnId 추가!
171180
onClose={() => setIsEditModalOpen(false)}
172181
onSubmit={async (data) => {
182+
const matchedColumn = columns.find(
183+
(col) => col.title === data.status
184+
); // title → id
185+
173186
await updateCardMutate({
174-
status: String(cardData.columnId) || cardData.status,
187+
columnId: matchedColumn?.id, // ✅ columnId로 넘기기!
175188
assignee: { ...cardData.assignee, nickname: data.assignee },
176189
title: data.title,
177190
description: data.description,
178191
dueDate: data.deadline,
179192
tags: data.tags,
180193
imageUrl: data.image ?? "",
181194
});
182-
setIsEditModalOpen(false); // 수정 후 모달 닫기
195+
196+
setIsEditModalOpen(false);
183197
}}
184198
initialData={{
185-
status: cardData.status,
199+
status: columnName,
186200
assignee: cardData.assignee.nickname,
187201
title: cardData.title,
188202
description: cardData.description,

0 commit comments

Comments
 (0)