Skip to content

Commit a998c01

Browse files
authored
Merge pull request #254 from manNomi/fix/university
hot fix: application endpoint 수정했습니다
2 parents fa30c76 + 635dd69 commit a998c01

2 files changed

Lines changed: 40 additions & 2 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { AxiosError, AxiosResponse } from "axios";
2+
3+
import { axiosInstance } from "@/utils/axiosInstance";
4+
5+
import { QueryKeys } from "./queryKeys";
6+
7+
import { ApplicationListResponse } from "@/types/application";
8+
9+
// UseQueryResult는 useQuery의 반환 타입을 명시할 때 유용합니다.
10+
import { UseQueryOptions, UseQueryResult, useQuery } from "@tanstack/react-query";
11+
12+
export const getCompetitorsApplicationList = (): Promise<AxiosResponse<ApplicationListResponse>> =>
13+
axiosInstance.get("/applications");
14+
15+
// 커스텀 훅의 props 타입 정의를 개선하여 queryKey와 queryFn을 제외시킵니다.
16+
type UseGetCompetitorsApplicationListOptions = Omit<
17+
UseQueryOptions<
18+
AxiosResponse<ApplicationListResponse>, // queryFn이 반환하는 원본 데이터 타입
19+
AxiosError<{ message: string }>, // 에러 타입
20+
ApplicationListResponse // select를 통해 최종적으로 반환될 데이터 타입
21+
>,
22+
"queryKey" | "queryFn" // 훅 내부에서 지정하므로 props에서는 제외
23+
>;
24+
25+
const useGetApplicationsList = (
26+
props?: UseGetCompetitorsApplicationListOptions,
27+
): UseQueryResult<ApplicationListResponse, AxiosError<{ message: string }>> => {
28+
// 반환 타입 명시
29+
return useQuery({
30+
queryKey: [QueryKeys.competitorsApplicationList],
31+
queryFn: getCompetitorsApplicationList,
32+
staleTime: 1000 * 60 * 5,
33+
select: (response) => response.data,
34+
...props,
35+
});
36+
};
37+
38+
export default useGetApplicationsList;

src/app/university/application/ScorePageContent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { REGIONS_KO } from "@/constants/university";
1616
import { ScoreSheet as ScoreSheetType } from "@/types/application";
1717
import { RegionKo } from "@/types/university";
1818

19-
import useGetCompetitorsApplicationList from "@/api/applications/client/useGetCompetitorsApplicationList";
19+
import useGetApplicationsList from "@/api/applications/client/useGetApplicationsList";
2020

2121
const PREFERENCE_CHOICE: ("1순위" | "2순위" | "3순위")[] = ["1순위", "2순위", "3순위"];
2222

@@ -46,7 +46,7 @@ const ScorePageContent = () => {
4646
};
4747

4848
// ✨ 2. `data`의 기본값을 위에서 정의한 initialData로 변경합니다.
49-
const { data: scoreResponseData = initialData, isLoading } = useGetCompetitorsApplicationList();
49+
const { data: scoreResponseData = initialData, isLoading } = useGetApplicationsList();
5050

5151
const filteredAndSortedData = useMemo(() => {
5252
// 데이터가 없는 경우를 대비한 방어 코드

0 commit comments

Comments
 (0)