Skip to content

Commit

Permalink
refactor: API 요청 함수 매개변수 구조 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
2yunseong committed Sep 10, 2024
1 parent 8a22e05 commit fbbf784
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
6 changes: 5 additions & 1 deletion frontend/components/interview/Board.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ const InterviewBoard = ({ generation }: InterviewBoardProps) => {
const { data, isLoading } = useQuery({
queryKey: ["allInterviewRecord", pageIndex, order, generation],
queryFn: () =>
getInterviewRecordByPageWithOrder(+pageIndex, order, generation),
getInterviewRecordByPageWithOrder({
page: +pageIndex,
sortType: order,
year: generation,
}),
});

if (!data || isLoading) {
Expand Down
7 changes: 6 additions & 1 deletion frontend/components/interview/PageNavbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ const InterviewPageNavbar = ({ generation }: InterviewPageNavbarProps) => {
isError,
} = useQuery(
["allApplicant", order, generation],
() => getInterviewRecordByPageWithOrder(+pageIndex, order, generation),
() =>
getInterviewRecordByPageWithOrder({
page: +pageIndex,
sortType: order,
year: generation,
}),
{
enabled: !!generation,
}
Expand Down
18 changes: 11 additions & 7 deletions frontend/src/apis/interview/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@ interface RecordsByPageRes {
pageInfo: PageInfo;
}

export const getInterviewRecordByPageWithOrder = async (
page: number,
order: string,
year: string
) => {
const sq = new URLSearchParams({ sortType: order, year });
interface GetInterviewRecordByPageWithOrderReq {
page: number;
sortType: string;
year: string;
}

export const getInterviewRecordByPageWithOrder = async ({
page,
...queryParams
}: GetInterviewRecordByPageWithOrderReq) => {
const {
data: { records, pageInfo },
} = await https.get<RecordsByPageRes>(
`/page/${page}/records?${sq.toString()}`
`/page/${page}/records?${new URLSearchParams(queryParams)}`
);

return {
Expand Down

0 comments on commit fbbf784

Please sign in to comment.