diff --git a/packages/admin/src/pages/winner/WinnerResult.tsx b/packages/admin/src/pages/winner/WinnerResult.tsx index b8fade57..8d858fed 100644 --- a/packages/admin/src/pages/winner/WinnerResult.tsx +++ b/packages/admin/src/pages/winner/WinnerResult.tsx @@ -6,6 +6,7 @@ import { Button } from 'src/components/ui/button.tsx'; import useEvent from 'src/hooks/useEvent.tsx'; import { QuizWinner, RacingWinner } from 'src/services/api/types/apiType.ts'; import { useAlert } from 'src/store/provider/AlertProvider.tsx'; +import { transformQuizWinnersToExcel, transformRaceWinnersToExcel } from 'src/utils/adaptor.ts'; import excelDownload from 'src/utils/xlsx.ts'; const TabName = { @@ -86,13 +87,13 @@ function WinnerResult() { if (quizWinner === undefined) { return openAlert('데이터가 없습니다.', 'alert'); } - excelDownload(quizWinner, '퀴즈 위너'); + excelDownload(transformQuizWinnersToExcel(quizWinner), '퀴즈 위너'); } if (tabName === TabName.RACE) { if (racingWinners === undefined) { return openAlert('데이터가 없습니다.', 'alert'); } - excelDownload(racingWinners, '레이싱 위너'); + excelDownload(transformRaceWinnersToExcel(racingWinners), '레이싱 위너'); } }; diff --git a/packages/admin/src/utils/adaptor.ts b/packages/admin/src/utils/adaptor.ts new file mode 100644 index 00000000..f31edd69 --- /dev/null +++ b/packages/admin/src/utils/adaptor.ts @@ -0,0 +1,18 @@ +import { QuizWinner, RacingWinner } from 'src/services/api/types/apiType.ts'; + +export function transformQuizWinnersToExcel(quizWinners: QuizWinner[]): object[] { + return quizWinners.map((winner) => ({ + 이름: winner.name, + 이메일: winner.phoneNumber, + 당첨일: winner.postDate, + })); +} +export function transformRaceWinnersToExcel(raceWinners: RacingWinner[]): object[] { + return raceWinners.map((winner) => ({ + 등: winner.rank, + 이름: winner.name, + 이메일: winner.phoneNumber, + 공유링크: winner.clickNumber, + 팀: winner.team, + })); +}