Skip to content

[refactor] fe 리팩토링#674

Merged
lepitaaar merged 3 commits intodevelop-fefrom
refactor/671-fe-refactor
Aug 18, 2025
Merged

[refactor] fe 리팩토링#674
lepitaaar merged 3 commits intodevelop-fefrom
refactor/671-fe-refactor

Conversation

@lepitaaar
Copy link
Contributor

@lepitaaar lepitaaar commented Aug 18, 2025

#️⃣연관된 이슈

appId -> applicantId
불필요한 status 제거
useMemo 삭제

📝작업 내용

이번 PR에서 작업한 내용을 간략히 설명해주세요(이미지/동영상 첨부 가능)

중점적으로 리뷰받고 싶은 부분(선택)

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요

ex) 메서드 XXX의 이름을 더 잘 짓고 싶은데 혹시 좋은 명칭이 있을까요?

논의하고 싶은 부분(선택)

논의하고 싶은 부분이 있다면 작성해주세요.

🫡 참고사항

Summary by CodeRabbit

  • 신기능

    • 지원자 상태 옵션을 간소화하고 일부 상태를 제거해 목록·상세 화면과 상태 그룹 표시를 더 명확하게 했습니다.
    • 거절(불합) 상태에 대한 명시적 라벨 추가 및 기본 표시 방식 유지.
  • 리팩터

    • 공개 API와 훅의 매개변수 명칭을 일관되게 정리했습니다(동작에는 영향 없음).
    • 지원자 상세 페이지의 조회 로직을 단순화해 유지보수성을 향상시켰습니다.

@lepitaaar lepitaaar self-assigned this Aug 18, 2025
@lepitaaar lepitaaar added 🔨 Refactor 코드 리팩토링 💻 FE Frontend labels Aug 18, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 18, 2025

Warning

.coderabbit.yaml has a parsing error

The CodeRabbit configuration file in this repository has a parsing error and default settings were used instead. Please fix the error(s) in the configuration file. You can initialize chat with CodeRabbit to get help with the configuration file.

💥 Parsing errors (1)
Validation error: Invalid regex pattern for base branch. Received: "**" at "reviews.auto_review.base_branches[0]"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Walkthrough

프런트엔드에서 applicant 업데이트 API와 관련 훅의 파라미터명을 appId에서 applicantId로 변경했고, ApplicantDetailPage에서 useMemo를 제거해 직접 인덱스/객체 조회로 간단화했습니다. 또한 ApplicationStatus 열거형과 상태 매핑을 축소/재정렬했습니다.

Changes

Cohort / File(s) Summary
API: updateApplicantDetail 시그니처 변경
frontend/src/apis/application/updateApplicantDetail.ts
updateApplicantDetail의 4번째 파라미터명을 appIdapplicantId로 변경하고 요청 URL에서 해당 식별자를 사용하도록 수정. 기타 로직 불변.
Hook: useUpdateApplicant 시그니처/호출부 정합
frontend/src/hooks/queries/applicants/useUpdateApplicant.ts
훅 시그니처의 두번째 파라미터명을 appIdapplicantId로 변경하고, updateApplicantDetail 호출에 applicantId를 전달하도록 수정. 동작 불변.
UI: ApplicantDetailPage 조회 방식 단순화 및 상태 목록 변경
frontend/src/pages/AdminPage/tabs/ApplicantsTab/ApplicantDetailPage/ApplicantDetailPage.tsx
useMemo 제거 후 findIndex와 인덱스 접근으로 applicantIndex/applicant 계산으로 변경. AVAILABLE_STATUSES에서 SCREENING 제거 및 일부 상태 목록 조정. 색상 매핑에서 SCREENING 관련 분기 제거.
Types: ApplicationStatus 축소
frontend/src/types/applicants.ts
ApplicationStatus에서 다수 상태(DRAFT, SCREENING, SCREENING_PASSED, SCREENING_FAILED, INTERVIEW_IN_PROGRESS, INTERVIEW_PASSED, INTERVIEW_FAILED, OFFERED, CANCELED_BY_APPLICANT 등)를 제거. 남은 값: SUBMITTED, INTERVIEW_SCHEDULED, ACCEPTED, DECLINED.
Utils: 상태 그룹 매핑 단순화
frontend/src/utils/mapStatusToGroup.ts
상태별 그룹 매핑을 간소화(예: SUBMITTED, INTERVIEW_SCHEDULED, ACCEPTED만 각각 매핑)하고 DECLINED를 명시적으로 추가. 기본 폴백은 동일.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers

  • Zepelown
  • oesnuj
  • PororoAndFriends
  • suhyun113

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/671-fe-refactor

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.

❤️ Share
🪧 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.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@vercel
Copy link

vercel bot commented Aug 18, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
moadong Ready Ready Preview Comment Aug 18, 2025 3:54am

Copy link
Member

@seongwon030 seongwon030 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

지원자 불합 상태 추가해놓을게용 고생하셨습니다!

status: ApplicationStatus,
clubId: string,
appId: string,
applicantId: string,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

가독성 좋네용

Comment on lines -48 to -49
const { applicant, applicantIndex } = useMemo(() => {
const index =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

일단은 제거 ~

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
frontend/src/utils/mapStatusToGroup.ts (2)

11-12: 레이블 용어 통일 여부 확인(‘불합’ vs ‘불합격’)

사용자 노출 텍스트로 보입니다. 기존 화면/문서에서 ‘불합격’을 썼다면 통일해 주세요.


3-16: switch 대신 상수 맵 + exhaustiveness 체크로 리팩토링 제안

상태 축소가 끝났으니 객체 맵으로 단순화하면 가독성이 좋아지고, 새 상태 추가 시 컴파일 타임에 누락을 잡기 쉽습니다.

예시:

const STATUS_MAP: Record<ApplicationStatus, { status: ApplicationStatus; label: string }> = {
  [ApplicationStatus.SUBMITTED]: { status: ApplicationStatus.SUBMITTED, label: '서류검토' },
  [ApplicationStatus.INTERVIEW_SCHEDULED]: { status: ApplicationStatus.INTERVIEW_SCHEDULED, label: '면접예정' },
  [ApplicationStatus.ACCEPTED]: { status: ApplicationStatus.ACCEPTED, label: '합격' },
  [ApplicationStatus.DECLINED]: { status: ApplicationStatus.DECLINED, label: '불합' },
};

const mapStatusToGroup = (status: ApplicationStatus) => STATUS_MAP[status];
frontend/src/pages/AdminPage/tabs/ApplicantsTab/ApplicantDetailPage/ApplicantDetailPage.tsx (3)

19-22: AVAILABLE_STATUSES에서 DECLINED(불합) 제외 — 의도 확인 필요

상태 enum에는 DECLINED가 남아 있고 mapStatusToGroup도 ‘불합’을 지원하지만, 선택 목록에서는 제외되어 있습니다. 관리자가 UI에서 불합 처리를 못 하게 하려는 의도인지 확인 부탁드립니다. 불합 선택이 필요하다면 아래처럼 추가하세요.

 const AVAILABLE_STATUSES = [
   ApplicationStatus.SUBMITTED, // 서류검토 (SUBMITTED 포함)
   ApplicationStatus.INTERVIEW_SCHEDULED, // 면접예정
   ApplicationStatus.ACCEPTED, // 합격
+  ApplicationStatus.DECLINED, // 불합
 ] as const;

참고: DECLINED 컬러가 필요하다면 getStatusColor에도 케이스를 추가해 주세요(예: '#FFECEC' 등 디자인 가이드에 맞춰).


47-49: useMemo 제거로 간결해졌지만, 파라미터 명은 applicantId로 정리 권장

로직 자체는 단순·명료해져서 좋습니다. 다만 라우트 파라미터 이름이 questionId로 남아 있어, 이번 PR 목표(appId → applicantId)와 불일치합니다. 가독성과 유지보수를 위해 applicantId로 통일하는 편이 좋습니다.

  • 제안: 라우트 파라미터, 훅 인자, 비교 로직 전반을 applicantId로 리네임
  • 대량 데이터에서 findIndex O(n)이 부담될 수 있다면, applicants를 id→index 맵으로 보관(컨텍스트 수준)하거나 useMemo로 메모이제이션 고려

리네임 예시(파일 전반):

// 라우트 파라미터
const { applicantId } = useParams<{ applicantId: string }>();

// 훅
const { mutate: updateApplicant } = useUpdateApplicant(clubId!, applicantId!);

// 조회
const applicantIndex = applicantsData?.applicants.findIndex((a) => a.id === applicantId) ?? -1;
const applicant = applicantsData?.applicants[applicantIndex];

// 내비게이션
onChange={(e) => navigate(`/admin/applicants/${e.target.value}`)}
navigate(`/admin/applicants/${previousData.id}`)
navigate(`/admin/applicants/${nextData.id}`)

47-49: 디바운스 지연값(400) 매직 넘버 상수화 제안

코드 전반의 의미 부여와 재사용을 위해 명명 상수로 추출해 주세요.

예시(파일 상단 혹은 핸들러 근처에 선언):

const UPDATE_DEBOUNCE_MS = 400;

사용처:

debounce((memo, status) => { /* ... */ }, UPDATE_DEBOUNCE_MS)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 6bfb0b0 and ce51459.

📒 Files selected for processing (2)
  • frontend/src/pages/AdminPage/tabs/ApplicantsTab/ApplicantDetailPage/ApplicantDetailPage.tsx (2 hunks)
  • frontend/src/utils/mapStatusToGroup.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
frontend/**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (frontend/.cursorrules)

frontend/**/*.{ts,tsx}: Replace magic numbers with named constants for clarity.
Replace complex or nested ternary operators with if/else statements or IIFEs for readability.
Assign complex boolean conditions to named variables.
Use consistent return types for similar functions and hooks.
Avoid hidden side effects; functions should only perform actions implied by their signature (Single Responsibility Principle).
Use unique, descriptive names for custom wrappers and functions to avoid ambiguity.
Define constants near related logic or ensure names link them clearly.

Files:

  • frontend/src/utils/mapStatusToGroup.ts
  • frontend/src/pages/AdminPage/tabs/ApplicantsTab/ApplicantDetailPage/ApplicantDetailPage.tsx
frontend/**/*.tsx

📄 CodeRabbit Inference Engine (frontend/.cursorrules)

frontend/**/*.tsx: Abstract complex logic/interactions into dedicated components or higher-order components (HOCs).
Separate significantly different conditional UI/logic into distinct components.
Colocate simple, localized logic or use inline definitions to reduce context switching.
Choose field-level or form-level cohesion based on form requirements.
Break down broad state management into smaller, focused hooks or contexts.
Use component composition instead of props drilling.

Files:

  • frontend/src/pages/AdminPage/tabs/ApplicantsTab/ApplicantDetailPage/ApplicantDetailPage.tsx
🔇 Additional comments (3)
frontend/src/utils/mapStatusToGroup.ts (1)

11-12: DECLINED 매핑 추가 합리적입니다

축소된 enum과 UI 흐름에 맞게 불합 처리 케이스를 명시해 둔 점 좋습니다.

frontend/src/pages/AdminPage/tabs/ApplicantsTab/ApplicantDetailPage/ApplicantDetailPage.tsx (2)

19-22: 레거시 상태 및 식별자 검증 완료
rg 검색 결과, 제거 대상이 된 ApplicationStatus 멤버와 appId/app_id 식별자가 코드베이스에서 모두 발견되지 않았습니다.
상태 축소 및 식별자 리네이밍이 전체 FE에 일관되게 적용된 것으로 보입니다.


47-49: clubId!, questionId! 단언 사용 안전성 강화 필요

useMutation에는 enabled 옵션이 제공되지 않으므로, clubIdapplicantIdundefined일 때에도 mutationFn이 호출되어 잘못된 API 요청이 전송될 수 있습니다. 컴포넌트 혹은 훅 내부에서 ID 존재 여부를 반드시 검사하여, undefined인 경우 네트워크 요청을 no-op 처리하거나 호출 자체를 차단하도록 보호 로직을 추가해주세요.

  • frontend/src/pages/AdminPage/tabs/ApplicantsTab/ApplicantDetailPage/ApplicantDetailPage.tsx (47–49):
    • clubId!, questionId! 단언 대신 if (!clubId || !questionId) return; 식의 null/undefined 체크를 적용
  • src/hooks/queries/applicants/useUpdateApplicant.ts:
    • mutationFn 실행 전에 clubId, applicantId 유효성 검사 후, 미정의 시 즉시 리턴하거나 dummy mutation 객체를 반환하도록 구현
⛔ Skipped due to 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')는 로그인 기능 구현 후 동적으로 가져오는 방식으로 수정될 예정입니다.

Copy link
Member

@Zepelown Zepelown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다

@lepitaaar lepitaaar merged commit fc25fc5 into develop-fe Aug 18, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💻 FE Frontend 🔨 Refactor 코드 리팩토링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments