From 4fd51201d558c253253f85be2f513165b40121a9 Mon Sep 17 00:00:00 2001 From: hyeonda02 Date: Thu, 27 Nov 2025 10:13:55 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Refactor=20:=20=EC=9D=B4=EB=B2=A4=ED=8A=B8?= =?UTF-8?q?=20=EB=8C=80=EC=8B=9C=EB=B3=B4=EB=93=9C=20=EC=AA=BD=20=EB=8B=89?= =?UTF-8?q?=EB=84=A4=EC=9E=84,=20=ED=94=84=EB=A1=9C=ED=95=84=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=20=EB=B0=98=EC=98=81=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/EventMainPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/EventMainPage.tsx b/src/pages/EventMainPage.tsx index dde3877..412e690 100644 --- a/src/pages/EventMainPage.tsx +++ b/src/pages/EventMainPage.tsx @@ -416,7 +416,7 @@ const handleSubmitGroupEdit = async () => { return { id: String(p.postId), - author: p.writerName ?? p.author ?? "익명", + author: p.writerNickname ?? p.author ?? "익명", content: p.content, type: isVote ? "vote" : "text", pollQuestion: p.voteTitle ?? p.pollQuestion ?? "", From 0af4d2ef7c4a4635f044c8fc11902436af4ba88a Mon Sep 17 00:00:00 2001 From: hyeonda02 Date: Thu, 27 Nov 2025 10:36:01 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Refactor=20:=20=ED=99=94=EB=A9=B4=20?= =?UTF-8?q?=EB=A0=8C=EB=8D=94=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80,?= =?UTF-8?q?=20=ED=94=84=EB=A1=9C=ED=95=84=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EB=B6=80=EB=B6=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 4 +- .env.development | 4 +- src/pages/EventMainPage.tsx | 86 +++++++++++++++++++++++++++++++++++-- 3 files changed, 86 insertions(+), 8 deletions(-) diff --git a/.env b/.env index 78761e5..c6ee8ff 100644 --- a/.env +++ b/.env @@ -1,3 +1,3 @@ -VITE_API_URL=https://api.eventee.cloud -VITE_GOOGLE_REDIRECT_URI=https://api.eventee.cloud/api/v1/auth/google +VITE_API_URL=http://localhost:8080 +VITE_GOOGLE_REDIRECT_URI=http://localhost:8080/api/v1/auth/google VITE_GOOGLE_CLIENT_ID=1311838165-j2g0s0tnb4hr1ptsksurpultd8uk14ov.apps.googleusercontent.com diff --git a/.env.development b/.env.development index c6ee8ff..78761e5 100644 --- a/.env.development +++ b/.env.development @@ -1,3 +1,3 @@ -VITE_API_URL=http://localhost:8080 -VITE_GOOGLE_REDIRECT_URI=http://localhost:8080/api/v1/auth/google +VITE_API_URL=https://api.eventee.cloud +VITE_GOOGLE_REDIRECT_URI=https://api.eventee.cloud/api/v1/auth/google VITE_GOOGLE_CLIENT_ID=1311838165-j2g0s0tnb4hr1ptsksurpultd8uk14ov.apps.googleusercontent.com diff --git a/src/pages/EventMainPage.tsx b/src/pages/EventMainPage.tsx index 412e690..8b5a0f7 100644 --- a/src/pages/EventMainPage.tsx +++ b/src/pages/EventMainPage.tsx @@ -25,7 +25,7 @@ type Comment = { author: string; content: string; timestamp: string; - imageUrl?: string; + writerProfileUrl?: string; isWrite: boolean; }; @@ -40,6 +40,7 @@ type PollOption = { type Post = { id: string; author: string; + writerProfileUrl: string; content: string; imageUrl?: string; likes: number; @@ -417,6 +418,7 @@ const handleSubmitGroupEdit = async () => { return { id: String(p.postId), author: p.writerNickname ?? p.author ?? "익명", + writerProfileUrl: p.writerProfileUrl, content: p.content, type: isVote ? "vote" : "text", pollQuestion: p.voteTitle ?? p.pollQuestion ?? "", @@ -424,7 +426,8 @@ const handleSubmitGroupEdit = async () => { createdAt: p.createdAt, comments: (p.comments ?? []).map((c: any) => ({ id: String(c.commentId ?? c.id), - author: c.writerNickname ?? c.writerName ?? c.author ?? "익명", + author: c.writerNickname ?? "익명", + writerProfileUrl: c.writerProfileUrl, content: c.content, timestamp: c.createdAt, isWrite: Boolean(c.isMine ?? c.isWrite), @@ -693,6 +696,65 @@ const handleSubmitGroupEdit = async () => { const displayNickname = location.state?.nickname ?? eventInfo?.nickname ?? "닉네임"; +useEffect(() => { + const interval = setInterval(async () => { + + const res = await apiFetch(`${API_URL}/api/v1/events/${eventId}/groups`); + const data = await res.json(); + if (!data.isSuccess) return; + + const newTeamsRaw = data.result.groups || []; + + const newTeamsWithPosts = await Promise.all( + newTeamsRaw.map(async (g: any) => { + const posts = await fetchGroupPosts(String(g.groupId)); + return { + ...g, + groupId: String(g.groupId), + posts, + }; + }) + ); + + setTeams((prev) => { + let changed = false; + + const updated = prev.map((oldTeam) => { + const newTeam = newTeamsWithPosts.find( + (t) => String(t.groupId) === String(oldTeam.id) + ); + if (!newTeam) return oldTeam; // 혹시 없는 경우 그대로 + + // 변경 여부 체크 + const oldPosts = JSON.stringify(oldTeam.posts); + const newPosts = JSON.stringify(newTeam.posts); + + if (oldPosts !== newPosts) { + changed = true; + return { + ...oldTeam, + posts: newTeam.posts, + // 필요한 경우 description, img, leader도 업데이트 가능 + }; + } + + return oldTeam; + }); + + if (changed) { + console.log("변경 감지 → 업데이트 실행"); + return updated; + } + + console.log("변화 없음 → UI 재렌더 생략"); + return prev; + }); + }, 10000); + + return () => clearInterval(interval); +}, [eventId]); + + return (
@@ -858,7 +920,15 @@ const handleSubmitGroupEdit = async () => { {/* 게시글 헤더 */}
-
+ {post.writerProfileUrl ? ( + + ) : ( +
+ )} + {post.author} @@ -974,7 +1044,15 @@ const handleSubmitGroupEdit = async () => { key={comment.id} className="flex gap-2" > -
+ {comment.writerProfileUrl ? ( + + ) : ( +
+ )} +