diff --git a/src/hooks/queries/friendship/useGetFriendships.ts b/src/hooks/queries/friendship/useGetFriendships.ts index d3aa89e..deceb7d 100644 --- a/src/hooks/queries/friendship/useGetFriendships.ts +++ b/src/hooks/queries/friendship/useGetFriendships.ts @@ -7,7 +7,7 @@ const useGetFriendships = ({ sort }: { sort: FriendshipSortType }) => { return useBaseInfiniteQuery({ queryKey: queryKeys.FRIENDSHIPS(sort), url: '/friendship', - sort, + params: { sort }, }); }; diff --git a/src/hooks/queries/useBaseInfiniteQuery.ts b/src/hooks/queries/useBaseInfiniteQuery.ts index 6f9bf3d..7757855 100644 --- a/src/hooks/queries/useBaseInfiniteQuery.ts +++ b/src/hooks/queries/useBaseInfiniteQuery.ts @@ -13,12 +13,12 @@ export const useBaseInfiniteQuery = ({ queryKey, url, size, - sort, + params, }: { queryKey: QueryKey; url: string; size?: number; - sort?: string; + params?: Record; }) => { const INITIAL_PAGE_PARAM = 0; const DEFAULT_SIZE = 10; @@ -28,13 +28,14 @@ export const useBaseInfiniteQuery = ({ ) => { const { pageParam = 0 } = context; - const queryParamString = buildQuery({ + const paginationParamString = buildQuery({ page: pageParam, size: size ?? DEFAULT_SIZE, - sort, }); - const URL = `${url}?${queryParamString}`; + const queryParamString = params ? `&${buildQuery(params)}` : ''; + + const URL = `${url}?${paginationParamString}${queryParamString}`; const response = await axiosInstance.get>>(URL); return response.data.data;