Skip to content

refactor:#256 마이페이지 > 자소서 리스트만 infiniteQuery 적용#258

Open
hye410 wants to merge 3 commits intodevfrom
Bugfix/#256-resume-list-bug
Open

refactor:#256 마이페이지 > 자소서 리스트만 infiniteQuery 적용#258
hye410 wants to merge 3 commits intodevfrom
Bugfix/#256-resume-list-bug

Conversation

@hye410
Copy link
Copy Markdown
Collaborator

@hye410 hye410 commented Apr 30, 2025

  • 다른 곳도 infiniteQuery를 적용하려다가 엮여 있는 것이 많아서 시간을 가지고 리팩토링 필요할 듯

💡 관련이슈

🍀 작업 요약

  • 마이페이지 내 자소서 리스트 infitnieQuery 적용

💬 리뷰 요구 사항

  • 다른 곳도 같이 적용하려 하였으나 엮여 있는 곳이 여럿이고
  • 30분 내에 재배포를 해야하는데 테스트할 시간이 부족하여
  • 현재 문제가 되는 상황만 먼저 해결하고 다시 리팩토링하겠습니다.
  • 마이페이지 내 자소서 리스트에 자소서 개수가 많아졌을 때 스크롤이 잘 작동하는지 확인 부탁드립니다.

💛 미리보기

✔️ 이슈 닫기

Closes #256
Ref #이슈번호 // 해당 이슈에 대한 작업이 완전히 끝나지 않은 경우

Summary by CodeRabbit

  • 신규 기능

    • 이력서 목록에 무한 스크롤(인피니티 스크롤) 기능이 추가되어 스크롤 시 자동으로 다음 페이지의 이력서가 불러와집니다.
  • 버그 수정

    • 이력서 목록에서 마지막 항목 구분 처리가 개선되어 시각적으로 더 깔끔하게 표시됩니다.
  • 리팩터

    • 이력서 아이템 컴포넌트에서 불필요한 prop이 제거되고, 새로운 prop으로 대체되었습니다.
    • API 클라이언트 서비스의 타입 정의와 함수명이 명확하게 변경되고, 쿼리 파라미터 처리 방식이 개선되었습니다.
    • 이력서 API 응답에 페이지네이션과 쿼리 파라미터 검증이 추가되어 안정성이 향상되었습니다.
  • 기타

    • 이력서 상태 상수가 readonly로 변경되어 타입 안정성이 강화되었습니다.

@hye410 hye410 added 🐞 BugFix Something isn't working 🔨 Refactor 코드 리팩토링 💎다혜 labels Apr 30, 2025
@hye410 hye410 self-assigned this Apr 30, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 30, 2025

"""

Walkthrough

이 변경사항은 마이페이지의 이력서 리스트에 무한 스크롤 기능을 도입하고, 스크롤이 적용되지 않는 버그를 수정합니다. API 엔드포인트가 페이지네이션을 지원하도록 확장되었으며, 프론트엔드에서는 새로운 무한 쿼리 훅과 스크롤 감지 훅이 도입되어 이력서 리스트를 페이지 단위로 불러오고, 사용자가 스크롤 하단에 도달하면 다음 페이지를 자동으로 요청합니다. 이와 함께 관련 컴포넌트와 타입 정의가 이에 맞게 리팩토링되었습니다.

Changes

파일/경로 그룹 변경 요약
src/app/api/resume/route.ts 이력서 API GET 핸들러에 페이지네이션 및 무한 스크롤 요청(reqType='infinity') 지원 추가, 쿼리 파라미터 정제 유틸리티 도입, 불필요한 import 및 404 처리 제거
src/constants/resume-constants.ts RESUME_STATUSas const로 변경하여 타입 엄격성 및 불변성 강화
src/features/interview/resume-all-modal.tsx ResumeItem 컴포넌트에서 hrOption={false} prop 제거
src/features/resume-list/hooks/use-resume-infinite-query.ts 새로운 무한 스크롤용 커스텀 훅 useResumeInfiniteQuery 추가
src/features/resume-list/resume-item.ts hrOption prop 제거, isLastChild prop 추가, <li>에 직접 border 스타일 적용, 불필요한 wrapper 제거
src/features/resume-list/resume-list.tsx 기존 쿼리 훅을 무한 쿼리 훅으로 교체, 무한 스크롤 감지 훅 도입, 리스트 렌더링 및 스타일 수정
src/features/resume/api/client-services.ts 타입을 ResumeType으로 교체, 페이지네이션 함수명 및 구현 변경, 반환 타입 단순화

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ResumeListComponent
    participant useResumeInfiniteQuery
    participant API
    User->>ResumeListComponent: 페이지 진입/스크롤 하단 도달
    ResumeListComponent->>useResumeInfiniteQuery: 다음 페이지 요청
    useResumeInfiniteQuery->>API: GET /api/resume?page=X&limit=8&reqType=infinity
    API-->>useResumeInfiniteQuery: { resumeList, nextPage }
    useResumeInfiniteQuery-->>ResumeListComponent: 데이터 및 nextPage 반환
    ResumeListComponent-->>User: 이력서 리스트 추가 렌더링
Loading

Assessment against linked issues

Objective Addressed Explanation
마이페이지 자소서 리스트 스크롤 적용 및 무한 스크롤 구현 (#256)

Suggested labels

🕶️ 재원

Suggested reviewers

  • parkminjo
  • choichangyeon

Poem

🐇
무한히 펼쳐지는 이력서의 길,
스크롤을 내릴 때마다 새롭게 빛나네.
페이지네이션 마법과 함께
토끼는 기쁘게 깡총깡총 춤을 춰요!
이제 리스트는 끝이 없고
사용자는 편하게,
코드도 깔끔하게!

"""


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 46a9370 and f47bd19.

📒 Files selected for processing (1)
  • src/features/resume/api/client-services.ts (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/features/resume/api/client-services.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Generate unit testing code for this file.
    • 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. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and generate unit testing code.
    • @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.

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 pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • 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

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.

Copy link
Copy Markdown

@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: 1

🧹 Nitpick comments (2)
src/features/resume-list/hooks/use-resume-infinite-query.ts (1)

8-8: 상수의 구성 가능성 고려

ITEM_PER_PAGE가 하드코딩되어 있습니다. 다른 컨텍스트에서 이 값이 변경될 필요가 있다면, 이 값을 매개변수로 받도록 설계하는 것이 더 유연할 수 있습니다.

src/app/api/resume/route.ts (1)

33-57: 무한 스크롤 기능 구현 로직 검토

페이지네이션 로직이 잘 구현되었습니다. 특히 다음과 같은 측면이 좋습니다:

  • 파라미터 유효성 검사
  • 데이터베이스 쿼리에 적절한 스킵/테이크 패턴 사용
  • 다음 페이지 존재 여부 계산

개선 제안:

  • 에러 메시지를 상수로 분리하여 다른 메시지 상수와 함께 관리하는 것이 좋을 것 같습니다.
  • 페이지와 리밋에 대한 기본값을 제공하면 클라이언트 측에서 이러한 파라미터를 생략해도 작동할 수 있을 것입니다.

무한 스크롤 로직을 더 견고하게 만들기 위해:

- if (reqType === 'infinity') {
+ if (reqType === 'infinity') {
+   // 기본값 설정으로 클라이언트 요청 유연성 향상
+   const pageNumber = Number(page || 1);
+   const limitNumber = Number(limit || 10);
  
-   const pageNumber = Number(page);
-   const limitNumber = Number(limit);

    if (isNaN(pageNumber) || isNaN(limitNumber)) {
-     return NextResponse.json({ message: '유효하지 않은 파라미터입니다.' }, { status: 400 });
+     return NextResponse.json({ message: GET_INVALID_PARAMETER }, { status: 400 });
    }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 28d62b8 and 97f374d.

📒 Files selected for processing (7)
  • src/app/api/resume/route.ts (1 hunks)
  • src/constants/resume-constants.ts (1 hunks)
  • src/features/interview/resume-all-modal.tsx (0 hunks)
  • src/features/resume-list/hooks/use-resume-infinite-query.ts (1 hunks)
  • src/features/resume-list/resume-item.tsx (1 hunks)
  • src/features/resume-list/resume-list.tsx (2 hunks)
  • src/features/resume/api/client-services.ts (4 hunks)
💤 Files with no reviewable changes (1)
  • src/features/interview/resume-all-modal.tsx
🧰 Additional context used
🧬 Code Graph Analysis (3)
src/features/resume-list/resume-item.tsx (1)
src/types/DTO/resume-dto.ts (1)
  • ResumeType (3-3)
src/features/resume-list/hooks/use-resume-infinite-query.ts (3)
src/constants/query-key.ts (1)
  • QUERY_KEY (1-13)
src/constants/resume-constants.ts (1)
  • RESUME_STATUS (1-4)
src/features/resume/api/client-services.ts (1)
  • getResumeListByInfinite (88-103)
src/features/resume-list/resume-list.tsx (4)
src/constants/my-page-constants.ts (1)
  • TABS (1-5)
src/constants/resume-constants.ts (1)
  • RESUME_STATUS (1-4)
src/features/resume-list/hooks/use-resume-infinite-query.ts (1)
  • useResumeInfiniteQuery (9-27)
src/hooks/customs/use-infinite-scroll.ts (1)
  • useInfiniteScroll (8-31)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (17)
src/constants/resume-constants.ts (1)

4-4: 타입 안전성 향상을 위한 좋은 변경입니다!

as const 를 추가하여 RESUME_STATUS 객체를 읽기 전용으로 만들고 리터럴 타입을 보존함으로써 타입 안전성을 높였습니다. 이는 새로운 무한 쿼리(infiniteQuery) 구현에서 이 상수가 타입 파라미터로 사용될 때 특히 유용합니다.

src/features/resume-list/hooks/use-resume-infinite-query.ts (1)

1-27: 무한 스크롤을 위한 훅 구현이 잘 되었습니다!

React Query의 useInfiniteQuery를 활용하여 이력서 목록의 무한 스크롤을 구현한 커스텀 훅이 깔끔하게 작성되었습니다. 타입 안전성을 보장하기 위해 RESUME_STATUS 타입을 적절히 활용한 점이 좋습니다.

src/features/resume-list/resume-item.tsx (3)

4-4: 컴포넌트 구조 개선이 잘 되었습니다!

hrOption 대신 더 명확한 의미의 isLastChild 프롭으로 변경한 것은 좋은 결정입니다. 이렇게 하면 컴포넌트의 의도가 더 명확해집니다.

Also applies to: 9-9, 12-12


17-17: 스타일링 접근 방식 개선

외부 <hr> 요소를 사용하는 대신 clsx를 활용하여 조건부 테두리 스타일을 적용하는 방식으로 변경한 것은 좋은 개선입니다. 이렇게 하면 DOM 구조가 더 간결해지고 의미론적으로도 더 명확합니다.


24-26: 타이포그래피에 'as' 속성 추가

Typography 컴포넌트에 as='span' 속성을 추가하여 명시적으로 HTML 요소 타입을 지정한 것은 좋은 접근입니다. 이는 의미론적으로 올바른 HTML 구조를 보장합니다.

Also applies to: 28-30

src/features/resume-list/resume-list.tsx (5)

4-8: 무한 스크롤 구현을 위한 적절한 의존성 추가

필요한 상수, 훅, 유틸리티를 정확히 임포트하고 있습니다. RESUME_STATUS에서 SUBMIT 상수를 추출하여 사용하는 것은 타입 안전성을 유지하는 좋은 방법입니다.

Also applies to: 12-12


15-19: 무한 스크롤 로직의 효과적인 구현

useResumeInfiniteQueryuseInfiniteScroll 훅을 활용하여 무한 스크롤 기능을 효과적으로 구현했습니다. 필요한 상태와 함수를 적절하게 추출하고 있습니다.


35-36: 데이터 처리 로직 개선

무한 쿼리 결과에서 모든 페이지의 데이터를 flatMap을 사용하여 단일 배열로 평탄화하는 접근 방식이 적절합니다. 이는 무한 스크롤 구현에서 일반적인 패턴입니다.


38-48: 의미론적 마크업과 스타일링 개선

<ul> 요소를 사용하여 의미론적으로 올바른 리스트 구조를 만들고, 스크롤 처리를 위한 CSS 클래스를 적절히 적용했습니다. isLastChild 프롭을 적절히 전달하는 것도 좋은 방법입니다.


49-51: 무한 스크롤 로딩 표시기 구현

스크롤 감지를 위한 참조 요소와 다음 페이지 로딩 중 상태를 보여주는 표시기가 잘 구현되어 있습니다. 사용자 경험 측면에서 로딩 상태를 표시하는 것은 매우 중요합니다.

src/app/api/resume/route.ts (3)

8-8: sanitizeQueryParams 유틸리티 추가로 코드 품질 향상

새로운 유틸리티 함수를 사용하여 쿼리 파라미터를 안전하게 처리하는 방식은 좋은 접근입니다. 이는 입력값 검증 및 타입 변환에 대한 일관된 처리를 보장합니다.


23-31: 쿼리 파라미터 추출 개선

userId를 한 번만 추출하여 변수에 저장한 방식과 검색 파라미터를 명확하게 구조화한 접근 방식이 좋습니다. sanitizeQueryParams를 활용하여 모든 파라미터를 한 번에 처리하는 것은 코드 가독성과 유지보수성을 향상시킵니다.


59-67: 기존 쿼리 로직 변경 검토

userId 변수를 추출하여 재사용하는 방식으로 변경한 것은 좋은 리팩토링입니다. 이는 코드 중복을 줄이고 일관성을 향상시킵니다.

src/features/resume/api/client-services.ts (4)

5-5: 타입 임포트 변경

Prisma의 Resume 타입 대신 DTO 모듈에서 ResumeType을 사용하는 것으로 변경한 것은 좋은 접근입니다. 이는 데이터 전송 객체를 명확하게 정의하고 사용함으로써 API 계약을 더 명확하게 합니다.


17-17: 타입 참조 업데이트

Resume['id']에서 ResumeType['id']로 변경된 것은 일관성 있고 적절한 변경입니다.


67-67: 반환 타입 업데이트

getResumeList 함수의 반환 타입을 ResumeType[]으로 변경한 것은 앞서 변경된 타입 임포트와 일관성이 있습니다.


109-109: 반환 타입 업데이트

getResume 함수의 반환 타입을 ResumeType으로 변경한 것은 적절하고 일관성 있는 변경입니다.

Comment thread src/features/resume/api/client-services.ts
hye410 added 2 commits April 30, 2025 16:37
- 다른 곳도 infiniteQuery를 적용하려다가 엮여 있는 것이 많아서 시간을 가지고 리팩토링 필요할 듯
@hye410 hye410 force-pushed the Bugfix/#256-resume-list-bug branch from 97f374d to 46a9370 Compare April 30, 2025 07:44
Copy link
Copy Markdown
Collaborator

@choichangyeon choichangyeon left a comment

Choose a reason for hiding this comment

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

수고 많으셨습니다!

Copy link
Copy Markdown
Collaborator

@ImJaeOne ImJaeOne left a comment

Choose a reason for hiding this comment

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

ㅜㅜ후반에 고생이 너무 많으십니다 감사합니다~!!!

Copy link
Copy Markdown
Collaborator

@parkminjo parkminjo left a comment

Choose a reason for hiding this comment

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

너무 고생 많으셨습니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 BugFix Something isn't working 💎다혜 🔨 Refactor 코드 리팩토링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bugfix] 마이페이지 > 이력서 리스트 스크롤 미적용

4 participants