Skip to content

Commit 9c5cbfc

Browse files
committed
refact/테스트용 디버깅
1 parent 1da6d1d commit 9c5cbfc

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

src/mocks/handlers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ export const handlers = [
467467
const list = commentsStore[pid] ?? []
468468
const results = list.map((c) => ({
469469
...c,
470-
is_author: authenticated ? c.author.id === 1 : undefined,
470+
is_author: authenticated ? c.author.id === 99 : undefined,
471471
}))
472472

473473
return HttpResponse.json({
@@ -505,7 +505,7 @@ export const handlers = [
505505
const newComment: Comment = {
506506
id: nextCommentId++,
507507
content,
508-
author: { id: 1, nickname: '로그인유저', profile_img_url: null },
508+
author: { id: 99, nickname: '로그인유저', profile_img_url: null },
509509
created_at: nowISO(),
510510
updated_at: nowISO(),
511511
}

src/pages/community/CommunityDetailPage.tsx

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,7 @@ export default function CommunityDetailPage() {
7878
const [currentUserId, setCurrentUserId] = useState<number | null>(null)
7979

8080
// 현재 로그인한 사용자가 게시글 작성자인지 확인 (currentUserId와 post.author.id 비교)
81-
const isAuthor = loggedIn && currentUserId !== null && post !== null && post.author.id === currentUserId
82-
83-
// 디버깅용 로그
84-
console.log('=== isAuthor 판단 ===')
85-
console.log('loggedIn:', loggedIn)
86-
console.log('currentUserId:', currentUserId)
87-
console.log('post?.author?.id:', post?.author?.id)
88-
console.log('isAuthor 결과:', isAuthor)
81+
const isAuthor = loggedIn && currentUserId !== null && post !== null && Number(post.author.id) === Number(currentUserId)
8982

9083
// 무한 스크롤
9184
const [page, setPage] = useState(1)
@@ -145,7 +138,6 @@ export default function CommunityDetailPage() {
145138
try {
146139
const userData = await getCurrentUser()
147140
setCurrentUserId(userData.id)
148-
console.log('현재 로그인한 사용자 ID:', userData.id)
149141
} catch (err) {
150142
console.error('사용자 정보 조회 실패:', err)
151143
setCurrentUserId(null)
@@ -797,7 +789,8 @@ export default function CommunityDetailPage() {
797789
<span className="text-[16px] text-[#9D9D9D]">
798790
{formatTimeAgo(comment.created_at)}
799791
</span>
800-
{loggedIn && currentUserId === comment.author.id && (
792+
793+
{loggedIn && Number(currentUserId) === Number(comment.author.id) && (
801794
<>
802795
<span className="text-[16px] text-[#9D9D9D]">|</span>
803796
<button
@@ -913,4 +906,4 @@ export default function CommunityDetailPage() {
913906
)}
914907
</div>
915908
)
916-
}
909+
}

0 commit comments

Comments
 (0)