[feature] 비참여 동아리 상세페이지 접근 시 alert 처리#548
Conversation
- 클럽 상세 정보 조회 후, 해당 동아리 이름이 목록에 포함되어 있으면 alert를 띄우고 메인 페이지로 리다이렉트
✅ Deploy Preview for moadong ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Warning
|
| 파일/경로 | 변경 요약 |
|---|---|
| frontend/src/pages/ClubDetailPage/ClubDetailPage.tsx | 미가입 클럽 이름 배열, blockState 상태, 접근 차단 useEffect, alert 및 홈 이동, 렌더 조건 수정 등 접근 제어 로직 추가 |
Sequence Diagram(s)
sequenceDiagram
participant User
participant ClubDetailPage
participant Router
User->>ClubDetailPage: 상세페이지 접근
ClubDetailPage->>ClubDetailPage: 클럽 정보 fetch
ClubDetailPage->>ClubDetailPage: notJoinedClubNames 포함 여부 확인
alt 미가입 클럽일 때
ClubDetailPage->>User: alert("미가입 클럽입니다")
ClubDetailPage->>Router: navigate('/')
ClubDetailPage-->>User: 렌더링 차단(null 반환)
else 가입 클럽일 때
ClubDetailPage-->>User: 정상 렌더링
end
Possibly related issues
- [feature] MOA-89 비참여 동아리 상세페이지 접근 시 alert 처리 #547: 미가입(비참여) 동아리 상세페이지 접근 시 alert 처리 및 라우팅 차단 요구와 본 PR의 클라이언트 차단 및 alert 로직이 직접적으로 일치합니다.
✨ Finishing Touches
- 📝 Generate Docstrings
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.
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Explain this complex logic.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai explain this code block.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and explain its main purpose.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
There was a problem hiding this comment.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
frontend/src/pages/ClubDetailPage/ClubDetailPage.tsx (1)
17-95: 전반적인 아키텍처 권장사항현재 구현은 요구사항을 충족하지만, 프로덕션 환경을 위한 개선이 필요합니다:
- 서버 사이드 접근 제어: 클라이언트 사이드 검증은 보안상 우회 가능
- 동적 설정 관리: 하드코딩된 클럽 목록을 설정 파일이나 API로 관리
- 에러 바운더리: 접근 제어 실패시 적절한 에러 처리
- 로딩 UX: 접근 확인 중 로딩 인디케이터 표시
향후 개선 방향:
// 1. API에서 접근 권한 정보 포함 interface ClubDetail { // ... 기존 필드들 isAccessible: boolean; accessDeniedReason?: string; } // 2. 커스텀 훅으로 접근 제어 로직 분리 const useClubAccessControl = (clubDetail: ClubDetail) => { // 접근 제어 로직 };
🧹 Nitpick comments (1)
frontend/src/pages/ClubDetailPage/ClubDetailPage.tsx (1)
70-80: 접근 제어 로직은 올바르지만 UX 개선 필요핵심 로직은 정확하고 의존성 배열도 적절합니다. 하지만 사용자 경험을 개선할 수 있습니다:
- Alert 대신 모달이나 토스트 사용 권장
- 사용자에게 더 친화적인 메시지 제공
- 로딩 상태 표시 고려
// 개선안: 토스트 라이브러리 사용 예시 import { toast } from 'react-toastify'; // useEffect 내부에서 if (notJoinedClubNames.includes(clubDetail?.name || '')) { setBlockState('blocked'); toast.warn('현재 참여하지 않는 동아리입니다.', { position: 'top-center', autoClose: 3000, }); navigate('/', { replace: true }); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
frontend/src/pages/ClubDetailPage/ClubDetailPage.tsx(3 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: seongwon030
PR: Moadong/moadong#195
File: frontend/src/pages/AdminPage/AdminPage.tsx:7-7
Timestamp: 2025-03-19T05:18:07.818Z
Learning: AdminPage.tsx에서 현재 하드코딩된 클럽 ID('67d2e3b9b15c136c6acbf20b')는 로그인 기능 구현 후 동적으로 가져오는 방식으로 수정될 예정입니다.
frontend/src/pages/ClubDetailPage/ClubDetailPage.tsx (4)
Learnt from: seongwon030
PR: Moadong/moadong#195
File: frontend/src/pages/AdminPage/AdminPage.tsx:7-7
Timestamp: 2025-03-19T05:18:07.818Z
Learning: AdminPage.tsx에서 현재 하드코딩된 클럽 ID('67d2e3b9b15c136c6acbf20b')는 로그인 기능 구현 후 동적으로 가져오는 방식으로 수정될 예정입니다.
Learnt from: CR
PR: Moadong/moadong#0
File: frontend/.cursorrules:0-0
Timestamp: 2025-07-07T13:25:48.135Z
Learning: Applies to frontend/**/*.tsx : Separate significantly different conditional UI/logic into distinct components.
Learnt from: CR
PR: Moadong/moadong#0
File: frontend/.cursorrules:0-0
Timestamp: 2025-07-07T13:25:48.135Z
Learning: Applies to frontend/**/*.tsx : Break down broad state management into smaller, focused hooks or contexts.
Learnt from: CR
PR: Moadong/moadong#0
File: frontend/.cursorrules:0-0
Timestamp: 2025-07-07T13:25:48.135Z
Learning: Applies to frontend/**/*.tsx : Colocate simple, localized logic or use inline definitions to reduce context switching.
🧬 Code Graph Analysis (1)
frontend/src/pages/ClubDetailPage/ClubDetailPage.tsx (1)
frontend/src/hooks/queries/club/useGetClubDetail.ts (1)
useGetClubDetail(6-20)
🔇 Additional comments (3)
frontend/src/pages/ClubDetailPage/ClubDetailPage.tsx (3)
2-2: Import 추가 승인
useNavigate훅 import는 접근 제어 로직에서 필요한 네비게이션 기능을 위해 적절히 추가되었습니다.
64-67: 상태 관리 구조 승인
blockState를 통한 3단계 상태 관리('checking', 'blocked', 'allowed')는 렌더링 플로우를 명확하게 제어하며, 비동기 데이터 로딩과 접근 제어를 적절히 처리합니다.
93-95: 렌더링 조건 로직 승인
blockState !== 'allowed'조건을 포함한 렌더링 제어는 접근이 허용된 경우에만 컴포넌트가 렌더링되도록 적절히 구현되었습니다.

#️⃣연관된 이슈
📝작업 내용
고민한 부분
1번으로 하면 clubId를 상수로 관리해야 하는데 혹시 모를 보안문제가 생길 수도 있다고 판단했습니다.
추가로 커스텀 훅을 구현해야 하는 번거로움도 있을 것 같네요.
구현방식
✔️ 로딩 상태가 필요한 이유
clubDetailPage.tsx에서 렌더링 전에 (tanstack으로) clubDetail 값을 받기 떄문입니다.발생하는 문제
(1) mount
↓
(2) fetch clubDetail
↓
(3) clubDetail 도착
↓
(4) 렌더링 발생
↓
(5) useEffect → alert → navigate('/')
=> 렌더링 후 다시 리다이렉션되기에 깜빡거림이 발생합니다.
로딩 상태 추가
중점적으로 리뷰받고 싶은 부분(선택)
논의하고 싶은 부분(선택)
🫡 참고사항
Summary by CodeRabbit