Repository navigation
05.24 업데이트 - 책 이야기 카드에서 자기 자신 조회 시 리다이렉트 버그 수정 - #351
Conversation
Fix/349 book story mypage UI
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughProfileClient now redirects authenticated users to ChangesProfile Navigation Routing
Estimated Code Review Effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly Related Issues
Possibly Related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request implements a redirect mechanism in the ProfileClient to send logged-in users to their personal 'mypage' when accessing their own public profile URL. It also updates the profile link logic in the BookstoryDetail component to handle self-links and URI encoding. Review feedback identifies a potential routing issue where authorNickname should be used instead of authorId to ensure compatibility with the profile route, and suggests returning null during the redirect in ProfileClient to prevent UI flickering and redundant data fetching.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/app/(main)/profile/[nickname]/ProfileClient.tsx (1)
20-24: ⚡ Quick winConsider adding an early return to prevent flash of content.
The redirect happens in
useEffect, which runs after the component renders. This means users will briefly see the other user's profile UI before being redirected to/profile/mypage. Consider adding an early return before the JSX to prevent this flash:useEffect(() => { if (isLoggedIn && user?.nickname && user.nickname === nickname) { router.replace("/profile/mypage"); } }, [isLoggedIn, user?.nickname, nickname, router]); + if (isLoggedIn && user?.nickname && user.nickname === nickname) { + return null; // or return a loading spinner + } return ( <div className="flex flex-col items-center gap-[10px] md:gap-[24px] w-full min-h-screen bg-[`#F9F7F6`] pb-[100px]">🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/app/`(main)/profile/[nickname]/ProfileClient.tsx around lines 20 - 24, The component currently redirects inside useEffect causing a flash of the other user's profile; add an early return at the top of the ProfileClient component that checks the same condition (isLoggedIn && user?.nickname && user.nickname === nickname) and returns a placeholder (e.g., null or a small loading/redirecting UI) so the JSX for the other user's profile does not render before router.replace is run; keep the existing useEffect/router.replace logic but guard rendering with this early return to prevent the flash.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/app/`(main)/profile/[nickname]/ProfileClient.tsx:
- Line 15: Routing and API nickname handling is inconsistent: decode/encode
flows differ between ProfileClient (const nickname =
decodeURIComponent(encodedNickname)), page.tsx generateMetadata (uses
encodedNickname directly in `/members/${encodedNickname}`), memberService
(URL-encodes), and UI links like FollowItem (build `/profile/${user.nickname}`
without encoding), which breaks names with reserved chars. Fix by choosing one
convention (treat route param as decoded) and apply it everywhere: always use
the route param decoded in ProfileClient and generateMetadata (decode
encodedNickname before using), URL-encode nicknames when constructing API paths
via memberService only, and ensure all link builders (e.g., FollowItem, any
hrefs to `/profile/${...}`) call encodeURIComponent(user.nickname) when
composing route URLs; update comparisons (user.nickname === nickname) to use the
same decoded canonical value from useAuthStore to keep self-redirect logic
consistent.
---
Nitpick comments:
In `@src/app/`(main)/profile/[nickname]/ProfileClient.tsx:
- Around line 20-24: The component currently redirects inside useEffect causing
a flash of the other user's profile; add an early return at the top of the
ProfileClient component that checks the same condition (isLoggedIn &&
user?.nickname && user.nickname === nickname) and returns a placeholder (e.g.,
null or a small loading/redirecting UI) so the JSX for the other user's profile
does not render before router.replace is run; keep the existing
useEffect/router.replace logic but guard rendering with this early return to
prevent the flash.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: deb6d44b-e54e-4b69-9fe7-e007cee831be
📒 Files selected for processing (2)
src/app/(main)/profile/[nickname]/ProfileClient.tsxsrc/components/base-ui/BookStory/Detatil/bookstory_detail.tsx
📌 개요 (Summary)
🛠️ 변경 사항 (Changes)
📸 스크린샷 (Screenshots)
(UI 변경 사항이 있다면 첨부해주세요)
✅ 체크리스트 (Checklist)
pnpm build)pnpm lint)Summary by CodeRabbit
Bug Fixes