Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions src/pages/myPage/MyPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,36 @@ interface MemberProfile {
name: string;
gender: 'MALE' | 'FEMALE';
generation: number;
major: 'FRONTEND' | 'BACKEND' | 'ANDROID' | 'IOS' | 'DESIGN';
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',
};
Comment on lines +17 to 47
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

안녕하세요! 카테고리 관련 데이터가 여러 파일에 중복으로 정의되어 있어 유지보수성을 개선할 점이 보입니다.

현재 카테고리(전공) 데이터는 다음과 같이 여러 곳에 흩어져 있습니다:

  • MyPage.tsx: MemberProfile 인터페이스의 major 타입
  • MyPage.tsx: majorToInterestMap 객체
  • SignupPage.tsx: interestList 배열
  • src/assets/shared/ListData.tsx: interestList 배열

이로 인해 새로운 카테고리를 추가하거나 수정할 때 여러 파일을 변경해야 하며, 이번 PR에서 GAME_DEVELOPMENTGAME_DEVELOP으로 수정하신 것처럼 불일치가 발생할 수 있습니다.

개선 제안:
src/assets/shared/ListData.tsx와 같은 공통 파일에 카테고리 데이터를 중앙에서 관리하는 것을 제안합니다. 예를 들어, 다음과 같은 구조를 사용할 수 있습니다.

// src/assets/shared/ListData.tsx (예시)
export const CATEGORIES = [
  { key: 'FRONTEND', label: 'FE' },
  { key: 'BACKEND', label: 'BE' },
  { key: 'ANDROID', label: 'Android' },
  // ... 나머지 카테고리
] as const;

// 카테고리 키를 기반으로 Major 타입 생성
export type Major = typeof CATEGORIES[number]['key'];

// MyPage에서 사용할 Map과 List
export const majorToInterestMap: Record<Major, string> = Object.fromEntries(
  CATEGORIES.map(c => [c.key, c.label])
);
export const interestListForMyPage = CATEGORIES.map(c => ({ id: c.label, label: c.label }));

// SignupPage에서 사용할 List
export const interestListForSignup = CATEGORIES.map(c => ({ id: c.key, label: c.label }));

이렇게 하면,

  1. CATEGORIES 배열만 수정하면 모든 관련 타입과 데이터가 자동으로 업데이트됩니다.
  2. MyPage.tsxSignupPage.tsx에서는 이 중앙 데이터를 가져와 사용하면 되므로 코드 중복이 사라지고 일관성이 유지됩니다.
  3. major 타입도 import하여 사용할 수 있습니다.

이 리팩토링을 통해 앞으로 카테고리 관리가 훨씬 쉬워질 것입니다. 검토 부탁드립니다!


export default function MyPage() {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/signup/SignupPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default function SignupPage() {
{ id: 'IT_NETWORK', label: 'IT Network' },
{ id: 'FLUTTER', label: 'Flutter' },
{ id: 'CYBER_SECURITY', label: 'Cyber Security' },
{ id: 'GAME_DEVELOPMENT', label: 'Game Development' },
{ id: 'GAME_DEVELOP', label: 'Game Development' },
{ id: 'CLOUD_COMPUTING', label: 'Cloud Computing' },
];

Expand Down
Loading