From 8a22e059b546268dccdaddd7e402cf694787e798 Mon Sep 17 00:00:00 2001 From: 2yunseong Date: Tue, 10 Sep 2024 19:53:09 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=EB=A9=B4=EC=A0=91=EC=9E=90=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20API=20=EC=BF=BC=EB=A6=AC=20=ED=8C=8C?= =?UTF-8?q?=EB=9D=BC=EB=AF=B8=ED=84=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/(WithNavbar)/interview/[generation]/page.tsx | 2 +- frontend/components/interview/Board.tsx | 11 ++++++++--- frontend/components/interview/PageNavbar.tsx | 4 ++-- frontend/src/apis/interview/index.ts | 6 ++++-- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/frontend/app/(WithNavbar)/interview/[generation]/page.tsx b/frontend/app/(WithNavbar)/interview/[generation]/page.tsx index f8a98a08..3d04b063 100644 --- a/frontend/app/(WithNavbar)/interview/[generation]/page.tsx +++ b/frontend/app/(WithNavbar)/interview/[generation]/page.tsx @@ -17,7 +17,7 @@ const InterviewPage = ({ params: { generation } }: InterviewPageProps) => { - + ); diff --git a/frontend/components/interview/Board.tsx b/frontend/components/interview/Board.tsx index c9af9f3f..d80fe802 100644 --- a/frontend/components/interview/Board.tsx +++ b/frontend/components/interview/Board.tsx @@ -11,7 +11,11 @@ import { getInterviewRecordByPageWithOrder } from "@/src/apis/interview"; import { ORDER_MENU } from "@/src/constants"; import { useSearchQuery } from "@/src/hooks/useSearchQuery"; -const InterviewBoard = () => { +interface InterviewBoardProps { + generation: string; +} + +const InterviewBoard = ({ generation }: InterviewBoardProps) => { const [applicantId, setApplicantId] = useAtom(interViewApplicantIdState); const searchParams = useSearchParams(); const pageIndex = searchParams.get("page") || "1"; @@ -31,8 +35,9 @@ const InterviewBoard = () => { }; const { data, isLoading } = useQuery({ - queryKey: ["allInterviewRecord", pageIndex, order], - queryFn: () => getInterviewRecordByPageWithOrder(+pageIndex, order), + queryKey: ["allInterviewRecord", pageIndex, order, generation], + queryFn: () => + getInterviewRecordByPageWithOrder(+pageIndex, order, generation), }); if (!data || isLoading) { diff --git a/frontend/components/interview/PageNavbar.tsx b/frontend/components/interview/PageNavbar.tsx index 2b9f23ca..4208c68b 100644 --- a/frontend/components/interview/PageNavbar.tsx +++ b/frontend/components/interview/PageNavbar.tsx @@ -29,8 +29,8 @@ const InterviewPageNavbar = ({ generation }: InterviewPageNavbarProps) => { isLoading, isError, } = useQuery( - ["allApplicant", generation], - () => getInterviewRecordByPageWithOrder(+pageIndex, order), + ["allApplicant", order, generation], + () => getInterviewRecordByPageWithOrder(+pageIndex, order, generation), { enabled: !!generation, } diff --git a/frontend/src/apis/interview/index.ts b/frontend/src/apis/interview/index.ts index e7fbd4fc..40c5a7d0 100644 --- a/frontend/src/apis/interview/index.ts +++ b/frontend/src/apis/interview/index.ts @@ -21,12 +21,14 @@ interface RecordsByPageRes { export const getInterviewRecordByPageWithOrder = async ( page: number, - order: string + order: string, + year: string ) => { + const sq = new URLSearchParams({ sortType: order, year }); const { data: { records, pageInfo }, } = await https.get( - `/page/${page}/records?sortType=${order}` + `/page/${page}/records?${sq.toString()}` ); return { From fbbf784e5bf4a4619e7d708e26a4ff8932575107 Mon Sep 17 00:00:00 2001 From: 2yunseong Date: Tue, 10 Sep 2024 19:57:03 +0900 Subject: [PATCH 2/2] =?UTF-8?q?refactor:=20API=20=EC=9A=94=EC=B2=AD=20?= =?UTF-8?q?=ED=95=A8=EC=88=98=20=EB=A7=A4=EA=B0=9C=EB=B3=80=EC=88=98=20?= =?UTF-8?q?=EA=B5=AC=EC=A1=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/components/interview/Board.tsx | 6 +++++- frontend/components/interview/PageNavbar.tsx | 7 ++++++- frontend/src/apis/interview/index.ts | 18 +++++++++++------- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/frontend/components/interview/Board.tsx b/frontend/components/interview/Board.tsx index d80fe802..d816f0fc 100644 --- a/frontend/components/interview/Board.tsx +++ b/frontend/components/interview/Board.tsx @@ -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) { diff --git a/frontend/components/interview/PageNavbar.tsx b/frontend/components/interview/PageNavbar.tsx index 4208c68b..2e3fe174 100644 --- a/frontend/components/interview/PageNavbar.tsx +++ b/frontend/components/interview/PageNavbar.tsx @@ -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, } diff --git a/frontend/src/apis/interview/index.ts b/frontend/src/apis/interview/index.ts index 40c5a7d0..a52e17c1 100644 --- a/frontend/src/apis/interview/index.ts +++ b/frontend/src/apis/interview/index.ts @@ -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( - `/page/${page}/records?${sq.toString()}` + `/page/${page}/records?${new URLSearchParams(queryParams)}` ); return {