Skip to content

Commit 5f3fb57

Browse files
authored
refactor: 신청 목록의 순서를 보여주는 방식 수정 (#295)
2 parents ba2de02 + 4728ad7 commit 5f3fb57

File tree

2 files changed

+50
-39
lines changed

2 files changed

+50
-39
lines changed

service-manager/src/components/apply-list/ApplyList.tsx

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,30 @@ export const ApplyList = ({ eventId }: ApplyListProps) => {
2525
const { sectorSettingData } = useSectorQueryById(eventId);
2626
const { onEmailTransmit } = useTransmitEmail(eventId);
2727

28+
const sectorFilteredRegistrations = registrations.filter(
29+
(registration) => registration.sectorNum === selectedSector,
30+
);
31+
2832
const exportXLSX = async () => {
2933
const data = sectorSettingData
30-
.map((sector) =>
31-
registrations
32-
.filter(
33-
(registration) => registration.sectorNum === sector.sectorNumber,
34-
)
35-
.map((registration) =>
36-
EXCEL_HEADERS.reduce(
37-
(acc, header) => ({
38-
...acc,
39-
...getExcelCellValue(header, registration, registrations),
40-
}),
41-
{},
42-
),
34+
.map((sector) => {
35+
const currentSectorRegistrations = registrations.filter(
36+
(registration) => registration.sectorNum === sector.sectorNumber,
37+
);
38+
return currentSectorRegistrations.map((registration) =>
39+
EXCEL_HEADERS.reduce(
40+
(acc, header) => ({
41+
...acc,
42+
...getExcelCellValue(
43+
header,
44+
registration,
45+
currentSectorRegistrations,
46+
),
47+
}),
48+
{},
4349
),
44-
)
50+
);
51+
})
4552
.flat();
4653

4754
const XLSX = await import('xlsx');
@@ -97,25 +104,21 @@ export const ApplyList = ({ eventId }: ApplyListProps) => {
97104
</tr>
98105
</thead>
99106
<tbody className="text-center">
100-
{registrations
101-
.filter(
102-
(registration) => registration.sectorNum === selectedSector,
103-
)
104-
.map((registration) => {
105-
return (
106-
<tr key={registration.id}>
107-
{TABLE_HEADERS.map((header) => (
108-
<td key={header.key}>
109-
{getTableCellValue(
110-
header.key,
111-
registration,
112-
registrations,
113-
)}
114-
</td>
115-
))}
116-
</tr>
117-
);
118-
})}
107+
{sectorFilteredRegistrations.map((registration) => {
108+
return (
109+
<tr key={registration.id}>
110+
{TABLE_HEADERS.map((header) => (
111+
<td key={header.key}>
112+
{getTableCellValue(
113+
header.key,
114+
registration,
115+
sectorFilteredRegistrations,
116+
)}
117+
</td>
118+
))}
119+
</tr>
120+
);
121+
})}
119122
</tbody>
120123
</table>
121124
</div>

service-manager/src/functions/apply.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@ import { EXCEL_HEADERS, TABLE_HEADERS } from '../constants/apply';
44
const getCellValue = (
55
headerKey: (typeof EXCEL_HEADERS)[number]['key'],
66
userInfo: RegistrationResponse,
7-
registrations: RegistrationResponse[],
7+
sectorFilteredRegistrations: RegistrationResponse[],
88
) => {
99
switch (headerKey) {
1010
case 'sector':
1111
return userInfo.sectorNum;
1212
case 'order':
13-
return registrations.findIndex((data) => data.id === userInfo.id) + 1;
13+
return (
14+
sectorFilteredRegistrations.findIndex(
15+
(data) => data.id === userInfo.id,
16+
) + 1
17+
);
1418
case 'name':
1519
return userInfo.name;
1620
case 'affiliation':
@@ -38,17 +42,21 @@ const getCellValue = (
3842
export const getTableCellValue = (
3943
headerKey: (typeof TABLE_HEADERS)[number]['key'],
4044
userInfo: RegistrationResponse,
41-
registrations: RegistrationResponse[],
45+
sectorFilteredRegistrations: RegistrationResponse[],
4246
) => {
43-
return getCellValue(headerKey, userInfo, registrations);
47+
return getCellValue(headerKey, userInfo, sectorFilteredRegistrations);
4448
};
4549

4650
export const getExcelCellValue = (
4751
headerKey: (typeof EXCEL_HEADERS)[number],
4852
userInfo: RegistrationResponse,
49-
registrations: RegistrationResponse[],
53+
sectorFilteredRegistrations: RegistrationResponse[],
5054
) => {
51-
const value = getCellValue(headerKey.key, userInfo, registrations);
55+
const value = getCellValue(
56+
headerKey.key,
57+
userInfo,
58+
sectorFilteredRegistrations,
59+
);
5260
return {
5361
[headerKey.label]: value,
5462
};

0 commit comments

Comments
 (0)