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 dde3877..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; @@ -416,7 +417,8 @@ const handleSubmitGroupEdit = async () => { return { id: String(p.postId), - author: p.writerName ?? p.author ?? "익명", + 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 ? ( + + ) : ( +
+ )} +