Skip to content

Commit 28ed14f

Browse files
committed
feat: store and render majors by code on web
1 parent 2c21ccb commit 28ed14f

12 files changed

Lines changed: 172 additions & 112 deletions

File tree

src/app/dashboard/core-applications/page.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react'
44
import Link from 'next/link'
55

66
import Loader from '@/components/ui/common/Loader'
7+
import { formatMajorLabel } from '@/constant/majorOptions'
78
import { useAuthenticatedApi } from '@/hooks/useAuthenticatedApi'
89

910
type RecruitCoreResultStatus = 'SUBMITTED' | 'IN_REVIEW' | 'ACCEPTED' | 'REJECTED'
@@ -341,7 +342,7 @@ export default function DashboardCoreApplicationsPage() {
341342
>
342343
<td className="px-4 py-3 typo-pc-b3">{application.name}</td>
343344
<td className="px-4 py-3 typo-pc-b3">{application.studentId}</td>
344-
<td className="px-4 py-3 typo-pc-b3">{application.major}</td>
345+
<td className="px-4 py-3 typo-pc-b3">{formatMajorLabel(application.major)}</td>
345346
<td className="px-4 py-3 typo-pc-b3">{application.team}</td>
346347
<td className="px-4 py-3 typo-pc-b3">{application.resultStatus}</td>
347348
<td className="px-4 py-3 typo-pc-b3">{formatDateTime(application.createdAt)}</td>
@@ -410,7 +411,7 @@ export default function DashboardCoreApplicationsPage() {
410411
<div className="mt-3 space-y-2 typo-pc-b3">
411412
<p>이름: {detail.snapshot.name}</p>
412413
<p>학번: {detail.snapshot.studentId}</p>
413-
<p>전공: {detail.snapshot.major}</p>
414+
<p>전공: {formatMajorLabel(detail.snapshot.major)}</p>
414415
<p>전화번호: {detail.snapshot.phone}</p>
415416
<p>이메일: {detail.snapshot.email}</p>
416417
<p>지원 팀: {detail.team}</p>

src/app/dashboard/members/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Link from 'next/link'
66
import Loader from '@/components/ui/common/Loader'
77
import UserDetailsModal from '@/components/admin/UserDetailsModal'
88
import { GdgSegmentedButton } from '@/components/ui/design-system'
9+
import { formatMajorLabel } from '@/constant/majorOptions'
910
import { useAuthenticatedApi } from '@/hooks/useAuthenticatedApi'
1011
import { formatPhoneNumberDisplay } from '@/utils/phoneNumber'
1112

@@ -264,7 +265,7 @@ export default function DashboardMembersPage() {
264265
members.map((member) => (
265266
<tr key={member.id} className="border-t border-white/10 bg-black">
266267
<td className="px-4 py-3 typo-pc-b3">{member.name}</td>
267-
<td className="px-4 py-3 typo-pc-b3">{member.major}</td>
268+
<td className="px-4 py-3 typo-pc-b3">{formatMajorLabel(member.major)}</td>
268269
<td className="px-4 py-3 typo-pc-b3">{member.studentId}</td>
269270
<td className="px-4 py-3 typo-pc-b3">
270271
{formatPhoneNumberDisplay(member.phoneNumber)}

src/app/dashboard/users/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react'
44
import Link from 'next/link'
55

66
import Loader from '@/components/ui/common/Loader'
7+
import { formatMajorLabel } from '@/constant/majorOptions'
78
import { useAuth } from '@/hooks/useAuth'
89
import { useAuthenticatedApi } from '@/hooks/useAuthenticatedApi'
910

@@ -350,7 +351,7 @@ export default function DashboardUsersPage() {
350351
<td className="px-4 py-3 typo-pc-b3">{user.id}</td>
351352
<td className="px-4 py-3 typo-pc-b3">{user.name}</td>
352353
<td className="px-4 py-3 typo-pc-b3">{user.email}</td>
353-
<td className="px-4 py-3 typo-pc-b3">{user.major || '-'}</td>
354+
<td className="px-4 py-3 typo-pc-b3">{formatMajorLabel(user.major)}</td>
354355
<td className="px-4 py-3 typo-pc-b3">{user.studentId || '-'}</td>
355356
<td className="px-4 py-3">
356357
{editable ? (

src/app/recruit/core/page.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
GdgInputField
1616
} from '@/components/ui/design-system'
1717
import { PrivacyPolicyNotice } from '@/components/ui/common/PrivacyPolicyNotice'
18+
import { normalizeMajorCode } from '@/constant/majorOptions'
1819
import { useAuthenticatedApi } from '@/hooks/useAuthenticatedApi'
1920
import { usePhoneNumber } from '@/hooks/usePhoneNumber'
2021
import { unwrapApiResponse } from '@/utils/api/unwrap'
@@ -272,7 +273,7 @@ export default function RecruitCore() {
272273
name: prev.name || payload.name || '',
273274
studentId: prev.studentId || payload.studentId || '',
274275
email: prev.email || payload.email || '',
275-
major: prev.major || payload.major || '',
276+
major: prev.major || normalizeMajorCode(payload.major) || '',
276277
phone: formatInput(prev.phone || payload.phone || '')
277278
}))
278279
} catch (error: any) {
@@ -439,7 +440,7 @@ export default function RecruitCore() {
439440
name: formData.name,
440441
studentId: formData.studentId,
441442
phone: toDigits(formData.phone),
442-
major: formData.major,
443+
major: normalizeMajorCode(formData.major),
443444
email: formData.email
444445
},
445446
team: formData.team,

src/components/admin/AdminDashboard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use client';
22

33
import React, { useMemo } from 'react';
4+
import { formatMajorLabel } from '@/constant/majorOptions';
45
import {
56
ResponsiveContainer,
67
PieChart,
@@ -21,7 +22,7 @@ function normalizeMembers(rawMembers = []) {
2122
return rawMembers.map((u) => ({
2223
id: u?.id ?? u?.member?.id,
2324
name: u?.name ?? u?.member?.name ?? '',
24-
major: u?.major ?? u?.member?.major ?? u?.member?.majors?.main ?? '기타',
25+
major: formatMajorLabel(u?.major ?? u?.member?.major ?? u?.member?.majors?.main ?? '기타'),
2526
admissionSemester: u?.admissionSemester ?? u?.member?.admissionSemester ?? '미상',
2627
studentId: String(u?.studentId ?? u?.member?.studentId ?? ''),
2728
isPayed: typeof (u?.isPayed ?? u?.member?.isPayed) === 'boolean' ? (u?.isPayed ?? u?.member?.isPayed) : false,
@@ -207,4 +208,3 @@ export default function AdminDashboard({ members = [], totalCount }) {
207208
);
208209
}
209210

210-

src/components/admin/AdminTableCell.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import React from 'react';
44
import { User, Chip, Checkbox } from '@nextui-org/react';
5+
import { formatMajorLabel } from '@/constant/majorOptions';
56

67
const statusColorMap = {
78
true: 'success',
@@ -28,7 +29,7 @@ export default function AdminTableCell({ user, columnKey, onTogglePay }) {
2829
case 'major':
2930
return (
3031
<div className='flex flex-col'>
31-
<p className='text-white text-bold text-sm capitalize'>{user.major}</p>
32+
<p className='text-white text-bold text-sm capitalize'>{formatMajorLabel(user.major)}</p>
3233
<p className='text-bold text-sm capitalize text-default-400'>{user.studentId}</p>
3334
</div>
3435
);
@@ -54,4 +55,3 @@ export default function AdminTableCell({ user, columnKey, onTogglePay }) {
5455
}
5556
}
5657

57-

src/components/admin/UserDetailsModal.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import React, { useEffect } from 'react';
44
import { Button } from '@nextui-org/react';
55
import clsx from 'clsx';
6+
import { formatMajorLabel } from '@/constant/majorOptions';
67
import { formatPhoneNumberDisplay } from '@/utils/phoneNumber';
78

89
const FIELD_LABELS = {
@@ -79,6 +80,9 @@ const formatFieldValue = (key, value) => {
7980
if (key === 'isPayed' && typeof value === 'boolean') {
8081
return value ? '입금 완료' : '미입금';
8182
}
83+
if (key === 'major' && typeof value === 'string') {
84+
return formatMajorLabel(value);
85+
}
8286
return formatValue(value);
8387
};
8488

src/components/auth/screen/AuthFindId.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import axios from 'axios';
88
import TransparentInput from '@/components/ui/input/TransparentInput';
99
import { usePhoneNumber } from '@/hooks/usePhoneNumber';
1010

11-
import { majorOptions } from '@/constant/majorOptions';
11+
import { majorOptions, normalizeMajorCode } from '@/constant/majorOptions';
1212

1313
export default function AuthFindId({ handleBackToLogin }) {
1414
const [name, setName] = useState('');
@@ -92,14 +92,14 @@ export default function AuthFindId({ handleBackToLogin }) {
9292
base: 'bg-[#1c1c1c] text-white',
9393
},
9494
}}
95-
selectedKeys={major}
96-
onSelectionChange={setMajor}
95+
selectedKeys={normalizeMajorCode(major)}
96+
onSelectionChange={(value) => setMajor(String(value ?? ''))}
9797
>
9898
{majorOptions.map((major) => (
9999
<AutocompleteSection title={major.title} key={major.title} showDivider>
100100
{major.items.map((item) => (
101-
<AutocompleteItem key={item.key} aria-label={item.value} value={item.value}>
102-
{item.value}
101+
<AutocompleteItem key={item.code} aria-label={item.label} value={item.code}>
102+
{item.label}
103103
</AutocompleteItem>
104104
))}
105105
</AutocompleteSection>

src/components/study/ui/card/ApplicantInfoList.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
// components
44
import GreenTextButton from "@/components/ui/button/GreenTextButton";
5+
import { formatMajorLabel } from '@/constant/majorOptions';
56

67
export default function ApplicantInfoList({
78
applications,
@@ -57,7 +58,7 @@ export default function ApplicantInfoList({
5758
onClick={() => handleApplicantDetailPopup(app.id)}
5859
>
5960
<td className="py-4">{app.name}</td>
60-
<td className="py-4">{app.major}</td>
61+
<td className="py-4">{formatMajorLabel(app.major)}</td>
6162
<td className="py-4">{app.studentId}</td>
6263
<td className="py-4 text-center">
6364
{/* 이미 처리된 지원자가 있으면 상태 뱃지 표시 */}
@@ -104,4 +105,4 @@ export default function ApplicantInfoList({
104105
</div>
105106
</div>
106107
);
107-
}
108+
}

src/components/study/ui/modal/ApplicantDetailModal.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { useEffect } from 'react';
44
import { Spinner } from "@nextui-org/react";
5+
import { formatMajorLabel } from '@/constant/majorOptions';
56

67
// API Services
78
import { useApplicantDetail } from '@/services/study/useApplicantDetail';
@@ -58,7 +59,7 @@ export default function ApplicantDetailModal({ apiClient, studyId, selectedAppli
5859
<th className="p-2 bg-gray-200 text-center">학번</th>
5960
</tr>
6061
<tr className="border-b-2 border-gray-400">
61-
<td className="p-2 border-r-2 border-gray-400 text-center">{applicantDetail.major}</td>
62+
<td className="p-2 border-r-2 border-gray-400 text-center">{formatMajorLabel(applicantDetail.major)}</td>
6263
<td className="p-2 text-center">{applicantDetail.studentId}</td>
6364
</tr>
6465
<tr className="border-b-2 border-gray-400">
@@ -108,4 +109,4 @@ export default function ApplicantDetailModal({ apiClient, studyId, selectedAppli
108109
</div>
109110
)
110111
);
111-
}
112+
}

0 commit comments

Comments
 (0)