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.

high

전곡(major) λͺ©λ‘μ΄ μ—¬λŸ¬ 곳에 μ€‘λ³΅μœΌλ‘œ μ •μ˜λ˜μ–΄ μžˆμ–΄ μœ μ§€λ³΄μˆ˜μ„±μ„ μ €ν•΄ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€.

  1. 이 파일 λ‚΄μ—μ„œμ˜ 쀑볡: MemberProfile μΈν„°νŽ˜μ΄μŠ€μ˜ major νƒ€μž…κ³Ό majorToInterestMap 객체에 전곡 λͺ©λ‘μ΄ μ€‘λ³΅μœΌλ‘œ ν•˜λ“œμ½”λ”©λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.
  2. 파일 κ°„μ˜ 쀑볡: src/pages/signup/SignupPage.tsx의 interestList와도 사싀상 λ™μΌν•œ 데이터가 μ€‘λ³΅λ˜κ³  μžˆμŠ΅λ‹ˆλ‹€.

μ΄λŸ¬ν•œ 쀑볡을 ν•΄κ²°ν•˜κ³  μ½”λ“œμ˜ νš¨μœ¨μ„±κ³Ό μœ μ§€λ³΄μˆ˜μ„±μ„ 높이기 μœ„ν•΄ 전곡 데이터λ₯Ό ν•œ κ³³μ—μ„œ κ΄€λ¦¬ν•˜λŠ” '단일 정보 μ†ŒμŠ€(Single Source of Truth)'λ₯Ό λ§Œλ“œλŠ” 것을 κ°•λ ₯히 ꢌμž₯ν•©λ‹ˆλ‹€. 예λ₯Ό λ“€μ–΄, src/assets/shared/ 디렉토리에 majors.ts 같은 νŒŒμΌμ„ λ§Œλ“€μ–΄ 전곡 데이터λ₯Ό μ€‘μ•™μ—μ„œ 관리할 수 μžˆμŠ΅λ‹ˆλ‹€.

μ œμ•ˆν•˜λŠ” λ¦¬νŒ©ν† λ§:

  1. 곡유 데이터 파일 생성 (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>;
  2. MyPage.tsx μˆ˜μ •:

    • major νƒ€μž…μ„ MajorId둜 κ΅μ²΄ν•˜κ³ , majorToInterestMapκ³Ό interestToMajorMap을 importν•˜μ—¬ μ‚¬μš©ν•©λ‹ˆλ‹€.
    • λΉ„νš¨μœ¨μ μΈ μ—­λ°©ν–₯ 탐색 둜직(Object.keys(...).find(...))을 interestToMajorMap을 μ‚¬μš©ν•œ O(1) νƒμƒ‰μœΌλ‘œ κ°œμ„ ν•  수 μžˆμŠ΅λ‹ˆλ‹€.
    // handleCategorySave ν•¨μˆ˜ λ‚΄λΆ€
    import { interestToMajorMap } from '@/assets/shared/majors';
    
    const majorKey = interestToMajorMap[tempSelectedInterest];
  3. SignupPage.tsx μˆ˜μ •:

    • interestListλ₯Ό ν•˜λ“œμ½”λ”©ν•˜λŠ” λŒ€μ‹  majorsλ₯Ό 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