Skip to content

refactor(frontend): DataTable 컴포넌트에서 테이블 로직을 커스텀 훅으로 분리#269

Merged
kubrickcode merged 1 commit intomainfrom
develop/shlee/268
Nov 29, 2025
Merged

refactor(frontend): DataTable 컴포넌트에서 테이블 로직을 커스텀 훅으로 분리#269
kubrickcode merged 1 commit intomainfrom
develop/shlee/268

Conversation

@kubrickcode
Copy link
Copy Markdown
Owner

정렬과 즐겨찾기 로직이 컴포넌트에 직접 포함되어 가독성이 떨어지고 재사용이 어려웠음

  • useTableSort: 정렬 상태 관리 및 행 정렬 로직 분리
  • useFavoriteRows: 즐겨찾기 행 분리 로직 추출
  • getRowProps 타입을 ComponentPropsWithoutRef로 개선

fix #268

@github-actions github-actions Bot added the refactor Refactoring code label Nov 28, 2025
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @kubrickcode, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 DataTable 컴포넌트의 유지보수성과 재사용성을 높이기 위해 핵심 로직을 커스텀 훅으로 분리하는 리팩토링을 수행합니다. 기존 컴포넌트 내부에 얽혀 있던 정렬 및 즐겨찾기 관리 로직을 외부로 추출하여 컴포넌트의 복잡성을 줄이고, 관련 로직을 독립적으로 테스트하고 재사용할 수 있도록 합니다. 또한, getRowProps의 타입 정의를 개선하여 개발 경험과 타입 안정성을 향상시키고, 관리자 페이지의 접근 제어 로직을 보다 선언적인 방식으로 변경했습니다.

Highlights

  • DataTable 로직 분리: DataTable 컴포넌트 내의 정렬 및 즐겨찾기 로직을 각각 useTableSortuseFavoriteRows 커스텀 훅으로 분리하여 컴포넌트의 가독성과 재사용성을 향상시켰습니다.
  • useTableSort 훅 도입: 테이블 정렬 상태 관리 및 행 정렬 로직을 캡슐화하는 useTableSort 커스텀 훅을 새로 추가했습니다.
  • useFavoriteRows 훅 도입: 즐겨찾기 행을 분리하고 관리하는 로직을 useFavoriteRows 커스텀 훅으로 추출했습니다.
  • getRowProps 타입 개선: DataTable의 getRowProps 타입 정의를 ComponentPropsWithoutRef<typeof Table.Row>로 개선하여 타입 안정성을 높였습니다.
  • 관리자 페이지 접근 로직 개선: 관리자 페이지의 권한 없는 사용자 리다이렉션 로직을 useEffectuseNavigate 대신 react-router-domNavigate 컴포넌트를 사용하여 선언적으로 변경했습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@kubrickcode
Copy link
Copy Markdown
Owner Author

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

이 PR은 DataTable 컴포넌트의 정렬 및 즐겨찾기 관련 로직을 useTableSortuseFavoriteRows라는 커스텀 훅으로 분리하여 코드의 모듈성, 재사용성, 가독성을 크게 향상시켰습니다. 이는 저장소의 코딩 컨벤션을 잘 따르는 훌륭한 리팩토링입니다. 또한 getRowProps의 타입을 개선하여 타입 안정성을 높이고, AdminPage의 리다이렉션 로직과 SearchInput의 상태 초기화 로직을 개선한 점도 긍정적입니다. 몇 가지 추가 개선을 위해 .gitignore 설정과 DataTableuseMemo 로직 간소화에 대한 제안을 남겼습니다. 전반적으로 훌륭한 작업입니다.

Comment thread src/frontend/.gitignore
Comment thread src/frontend/src/components/table/data-table.tsx Outdated
@kubrickcode
Copy link
Copy Markdown
Owner Author

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

이 PR은 DataTable 컴포넌트의 정렬 및 즐겨찾기 관련 로직을 각각 useTableSortuseFavoriteRows 커스텀 훅으로 분리하여 가독성과 재사용성을 높이는 좋은 리팩터링입니다. 로직 분리가 깔끔하게 이루어졌고, getRowProps의 타입을 개선하여 타입 안정성을 높인 점도 훌륭합니다. 코드 품질을 더욱 향상시키기 위해 몇 가지 개선점을 제안드립니다.

Comment thread src/frontend/src/components/table/hooks/use-table-sort.tsx
Comment thread src/frontend/src/components/table/data-table.tsx Outdated
Comment thread src/frontend/src/components/table/hooks/use-favorite-rows.tsx Outdated
Comment thread src/frontend/src/components/table/hooks/use-favorite-rows.tsx Outdated
정렬과 즐겨찾기 로직이 컴포넌트에 직접 포함되어 가독성이 떨어지고 재사용이 어려웠음

- useTableSort: 정렬 상태 관리 및 행 정렬 로직 분리
- useFavoriteRows: 즐겨찾기 행 분리 로직 추출
- getRowProps 타입을 ComponentPropsWithoutRef로 개선

fix #268
@kubrickcode kubrickcode merged commit ef5bb56 into main Nov 29, 2025
6 checks passed
@kubrickcode kubrickcode deleted the develop/shlee/268 branch November 29, 2025 10:41
@kubrickcode
Copy link
Copy Markdown
Owner Author

🎉 This PR is included in version 0.7.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

refactor Refactoring code released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DataTable 컴포넌트에서 테이블 로직을 커스텀 훅으로 분리

1 participant