77} from '../../hooks/react-query/useRegistration' ;
88import { useSectorQueryById } from '../../hooks/react-query/useSetting' ;
99import { ApplyCount } from './ApplyCount' ;
10+ import { EXCEL_HEADERS , TABLE_HEADERS } from '../../constants/apply' ;
11+ import { getExcelCellValue , getTableCellValue } from '../../functions/apply' ;
1012import ErrorBoundary from '../common/ErrorBoundary' ;
1113
1214interface ApplyListProps {
@@ -30,17 +32,15 @@ export const ApplyList = ({ eventId }: ApplyListProps) => {
3032 . filter (
3133 ( registration ) => registration . sectorNum === sector . sectorNumber ,
3234 )
33- . map ( ( registration , index ) => ( {
34- 구간 : registration . sectorNum ,
35- 순서 : index + 1 ,
36- 이름 : registration . name ,
37- 학과 : registration . department ,
38- 차량번호 : registration . carNumber ,
39- 학생번호 : registration . studentNumber ,
40- 경차여부 : registration . isCompact ? '경차' : '경차 아님' ,
41- 휴대폰번호 : registration . phoneNumber ,
42- 이메일 : registration . email ,
43- } ) ) ,
35+ . map ( ( registration ) =>
36+ EXCEL_HEADERS . reduce (
37+ ( acc , header ) => ( {
38+ ...acc ,
39+ ...getExcelCellValue ( header , registration , registrations ) ,
40+ } ) ,
41+ { } ,
42+ ) ,
43+ ) ,
4444 )
4545 . flat ( ) ;
4646
@@ -91,15 +91,9 @@ export const ApplyList = ({ eventId }: ApplyListProps) => {
9191 < table className = "w-full min-w-[50rem]" >
9292 < thead >
9393 < tr >
94- < th > 순서</ th >
95- < th > 이름</ th >
96- < th > 단과 대학</ th >
97- < th > 학과</ th >
98- < th > 차량 번호</ th >
99- < th > 학생 번호</ th >
100- < th > 경차 여부</ th >
101- < th > 휴대폰 번호</ th >
102- < th > 이메일</ th >
94+ { TABLE_HEADERS . map ( ( header ) => (
95+ < th key = { header . key } > { header . label } </ th >
96+ ) ) }
10397 </ tr >
10498 </ thead >
10599 < tbody className = "text-center" >
@@ -110,19 +104,15 @@ export const ApplyList = ({ eventId }: ApplyListProps) => {
110104 . map ( ( registration ) => {
111105 return (
112106 < tr key = { registration . id } >
113- < td >
114- { registrations . findIndex (
115- ( data ) => data . id === registration . id ,
116- ) + 1 }
117- </ td >
118- < td > { registration . name } </ td >
119- < td > { registration . affiliation } </ td >
120- < td > { registration . department } </ td >
121- < td > { registration . carNumber } </ td >
122- < td > { registration . studentNumber } </ td >
123- < td > { registration . isCompact ? '경차' : '경차 아님' } </ td >
124- < td > { registration . phoneNumber } </ td >
125- < td > { registration . email } </ td >
107+ { TABLE_HEADERS . map ( ( header ) => (
108+ < td key = { header . key } >
109+ { getTableCellValue (
110+ header . key ,
111+ registration ,
112+ registrations ,
113+ ) }
114+ </ td >
115+ ) ) }
126116 </ tr >
127117 ) ;
128118 } ) }
0 commit comments