From ad6e1e59eafe10c157a3403fe835122f9326e161 Mon Sep 17 00:00:00 2001 From: gahyeon Date: Fri, 16 Aug 2024 16:24:37 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=AC=B4=ED=95=9C=EC=8A=A4=ED=81=AC?= =?UTF-8?q?=EB=A1=A4=20sort=20=EC=A0=81=EC=9A=A9=20=EC=95=88=EB=90=98?= =?UTF-8?q?=EB=8A=94=20=EC=9D=B4=EC=8A=88=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../(with-layout)/mypage/wk-history/page.tsx | 2 +- src/app/_hooks/user/useGetMyWktHistoryQuery.ts | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/app/(route)/(user)/(with-layout)/mypage/wk-history/page.tsx b/src/app/(route)/(user)/(with-layout)/mypage/wk-history/page.tsx index 26e271e5..f0c21f76 100644 --- a/src/app/(route)/(user)/(with-layout)/mypage/wk-history/page.tsx +++ b/src/app/(route)/(user)/(with-layout)/mypage/wk-history/page.tsx @@ -72,7 +72,7 @@ const UserWkHistoryPage = () => { pageable: { page: 1, size: 10, - sort: param.order, + sort: selectedOrder, }, }); diff --git a/src/app/_hooks/user/useGetMyWktHistoryQuery.ts b/src/app/_hooks/user/useGetMyWktHistoryQuery.ts index 8ddbd106..3b1358a9 100644 --- a/src/app/_hooks/user/useGetMyWktHistoryQuery.ts +++ b/src/app/_hooks/user/useGetMyWktHistoryQuery.ts @@ -16,7 +16,7 @@ export const useGetMyWktHistoryQuery = ({ pageable: { page: number; size: number; - sort?: string; + sort: string; }; }) => { return useInfiniteQuery({ @@ -28,22 +28,29 @@ export const useGetMyWktHistoryQuery = ({ pageable, ], queryFn: async ({ pageParam = pageable }) => { + const { page, size, sort } = pageable; const res = await api.get(`/api/apply/my`, { params: { startDate, endDate, statuses, - ...pageParam, + page, + size, + sort, }, }); return userApplyListSchema.parse(res.data.data); }, - initialPageParam: { page: 1, size: 10 }, + initialPageParam: { page: 1, size: 10, sort: 'createdAt,DESC' }, getNextPageParam: (lastPage) => { return lastPage.pageInfo.totalElements === 0 || lastPage.pageInfo.totalPages - 1 === lastPage.pageInfo.pageNum ? undefined - : { page: lastPage.pageInfo.pageNum + 2, size: pageable.size }; + : { + page: lastPage.pageInfo.pageNum + 2, + size: pageable.size, + sort: pageable.sort, + }; }, }); };