Skip to content

Commit 92e17f2

Browse files
authored
Merge pull request #159 from rover1523/mypage
[Fix] 카드가 변경되지 않아도 모달을 닫을 때 새로고침되는 현상을 수정
2 parents 24a4aa2 + 69676e5 commit 92e17f2

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

src/api/columns.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,5 @@ export const getColumn = async ({
6161
dashboardId,
6262
},
6363
});
64-
console.log("🟦 서버 응답:", res.data);
65-
console.log("URL:", apiRoutes.columns(TEAM_ID));
66-
console.log("대시보드 ID:", dashboardId);
6764
return res.data.data;
6865
};

src/components/modalDashboard/CardDetailModal.tsx

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable react-hooks/rules-of-hooks */
21
import { useMemo, useRef, useState } from "react";
32
import { MoreVertical, X } from "lucide-react";
43
import CardDetail from "./CardDetail";
@@ -74,7 +73,28 @@ export default function CardDetailPage({
7473
}, 1500);
7574
},
7675
});
76+
const initialData = {
77+
title: card.title,
78+
description: card.description,
79+
dueDate: card.dueDate,
80+
tags: card.tags,
81+
assignee: card.assignee,
82+
};
7783

84+
const handleClose = () => {
85+
onClose();
86+
87+
const hasChanged =
88+
cardData.title !== initialData.title ||
89+
cardData.description !== initialData.description ||
90+
!isEqual(cardData.dueDate, initialData.dueDate) ||
91+
JSON.stringify(cardData.tags) !== JSON.stringify(initialData.tags) ||
92+
JSON.stringify(cardData.assignee) !==
93+
JSON.stringify(initialData.assignee);
94+
if (hasChanged) {
95+
router.reload(); // 수정된 게 있을 경우만 새로고침
96+
}
97+
};
7898
const handleCommentSubmit = () => {
7999
if (!commentText.trim()) return;
80100
createCommentMutate({
@@ -134,13 +154,7 @@ export default function CardDetailPage({
134154
)}
135155
</div>
136156

137-
<button
138-
onClick={() => {
139-
onClose();
140-
router.reload(); // ✅ Next.js 방식 리로드
141-
}}
142-
title="닫기"
143-
>
157+
<button onClick={handleClose} title="닫기">
144158
<X className="w-7 h-7 flex items-center justify-center hover:cursor-pointer" />
145159
</button>
146160
</div>

0 commit comments

Comments
 (0)