Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Summary of ChangesHello @g-hyxn, 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은 사용자 프로필 및 회원가입 페이지에서 사용되는 전공(major) 카테고리를 확장하고 관련 매핑을 업데이트하여 시스템의 유연성을 높이고 데이터 일관성을 확보합니다. 이를 통해 더 다양한 전공 분야를 지원하고, 사용자 경험을 개선하는 기반을 마련합니다. Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
이번 PR은 선택 가능한 전공 목록을 확장하는 내용을 담고 있습니다. 변경 사항 자체는 올바르게 적용되었으나, 이로 인해 MyPage.tsx, SignupPage.tsx 등 여러 파일에 걸쳐 전공 데이터가 중복으로 관리되고 있는 구조적인 문제가 드러났습니다. 코드의 유지보수성을 크게 향상시키고 비효율적인 로직을 개선하기 위해, 전공 데이터를 한 곳에서 관리하는 '단일 정보 소스(Single Source of Truth)' 방식으로 리팩토링하는 상세한 방법을 리뷰 코멘트로 제안드렸습니다.
| major: | ||
| | 'FRONTEND' | ||
| | 'BACKEND' | ||
| | 'ANDROID' | ||
| | 'IOS' | ||
| | 'MOBILE_ROBOTICS' | ||
| | 'DESIGN' | ||
| | 'DEVOPS' | ||
| | 'AI' | ||
| | 'IT_NETWORK' | ||
| | 'FLUTTER' | ||
| | 'CYBER_SECURITY' | ||
| | 'GAME_DEVELOP' | ||
| | 'CLOUD_COMPUTING'; | ||
| } | ||
|
|
||
| const majorToInterestMap: Record<string, string> = { | ||
| FRONTEND: 'FE', | ||
| BACKEND: 'BE', | ||
| ANDROID: 'AOS', | ||
| ANDROID: 'Android', | ||
| IOS: 'iOS', | ||
| MOBILE_ROBOTICS: 'Mobile Robotics', | ||
| DESIGN: 'Design', | ||
| DEVOPS: 'DevOps', | ||
| AI: 'AI', | ||
| IT_NETWORK: 'IT Network', | ||
| FLUTTER: 'Flutter', | ||
| CYBER_SECURITY: 'Cyber Security', | ||
| GAME_DEVELOP: 'Game Development', | ||
| CLOUD_COMPUTING: 'Cloud Computing', | ||
| }; |
There was a problem hiding this comment.
전공(major) 목록이 여러 곳에 중복으로 정의되어 있어 유지보수성을 저해하고 있습니다.
- 이 파일 내에서의 중복:
MemberProfile인터페이스의major타입과majorToInterestMap객체에 전공 목록이 중복으로 하드코딩되어 있습니다. - 파일 간의 중복:
src/pages/signup/SignupPage.tsx의interestList와도 사실상 동일한 데이터가 중복되고 있습니다.
이러한 중복을 해결하고 코드의 효율성과 유지보수성을 높이기 위해 전공 데이터를 한 곳에서 관리하는 '단일 정보 소스(Single Source of Truth)'를 만드는 것을 강력히 권장합니다. 예를 들어, src/assets/shared/ 디렉토리에 majors.ts 같은 파일을 만들어 전공 데이터를 중앙에서 관리할 수 있습니다.
제안하는 리팩토링:
-
공유 데이터 파일 생성 (
src/assets/shared/majors.ts):export const majors = [ { id: 'FRONTEND', label: 'FE' }, { id: 'BACKEND', label: 'BE' }, { id: 'ANDROID', label: 'Android' }, { id: 'IOS', label: 'iOS' }, { id: 'MOBILE_ROBOTICS', label: 'Mobile Robotics' }, { id: 'DESIGN', label: 'Design' }, { id: 'DEVOPS', label: 'DevOps' }, { id: 'AI', label: 'AI' }, { id: 'IT_NETWORK', label: 'IT Network' }, { id: 'FLUTTER', label: 'Flutter' }, { id: 'CYBER_SECURITY', label: 'Cyber Security' }, { id: 'GAME_DEVELOP', label: 'Game Development' }, { id: 'CLOUD_COMPUTING', label: 'Cloud Computing' }, ] as const; export type MajorId = typeof majors[number]['id']; export type MajorLabel = typeof majors[number]['label']; export const majorToInterestMap = Object.fromEntries( majors.map(m => [m.id, m.label]) ) as Record<MajorId, MajorLabel>; export const interestToMajorMap = Object.fromEntries( majors.map(m => [m.label, m.id]) ) as Record<MajorLabel, MajorId>;
-
MyPage.tsx수정:major타입을MajorId로 교체하고,majorToInterestMap과interestToMajorMap을 import하여 사용합니다.- 비효율적인 역방향 탐색 로직(
Object.keys(...).find(...))을interestToMajorMap을 사용한 O(1) 탐색으로 개선할 수 있습니다.
// handleCategorySave 함수 내부 import { interestToMajorMap } from '@/assets/shared/majors'; const majorKey = interestToMajorMap[tempSelectedInterest];
-
SignupPage.tsx수정:interestList를 하드코딩하는 대신majors를 import하여 사용합니다.
이렇게 변경하면 향후 전공 목록이 변경될 때 공유 파일 하나만 수정하면 되므로 코드 관리가 훨씬 쉬워지고, 성능도 개선됩니다.
💡 배경 및 개요
Resolves: #{이슈번호}
📃 작업내용
🙋♂️ 리뷰노트
✅ PR 체크리스트
.env,노션,README)"API 개발 완료됐어요","환경값 추가되었어요")🎸 기타