Skip to content

Commit

Permalink
Merge branch 'main' into epic/FE-54--detail-page
Browse files Browse the repository at this point in the history
  • Loading branch information
jisurk authored Aug 4, 2024
2 parents 406ebc4 + 2688439 commit 67903f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/apis/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ const queries = createQueryKeyStore({
queryKey: ['epigramComments', epigramId],
queryFn: ({ pageParam }: { pageParam?: number }) => getEpigramComments({ id: epigramId, limit: 3, cursor: pageParam }),
}),
getCommentList: (request: CommentRequestType) => ({
queryKey: ['epigramComments', request] as const,
queryFn: ({ pageParam }: { pageParam: number | undefined }) => getEpigramComments({ ...request, cursor: pageParam }),
}),
getMyComments: (request: CommentRequestType) => ({
queryKey: ['myEpigramComments', request],
queryFn: () => getMyEpigramComments(request),
Expand Down
8 changes: 5 additions & 3 deletions src/hooks/useEpigramCommentsQueryHook.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { InfiniteData, useInfiniteQuery } from '@tanstack/react-query';
import { CommentResponseType } from '@/schema/comment';
// hooks/useEpigramCommentHook.ts

import { useInfiniteQuery } from '@tanstack/react-query';
import queries from '@/apis/queries';
import { CommentResponseType } from '@/schema/comment';

const useEpigramCommentsQuery = (epigramId: number) =>
useInfiniteQuery<CommentResponseType, Error, InfiniteData<CommentResponseType>>({
...queries.epigramComment.getComments(epigramId),
initialPageParam: undefined,
getNextPageParam: (lastPage) => lastPage.nextCursor ?? undefined,
getNextPageParam: (lastPage: CommentResponseType) => lastPage.nextCursor ?? undefined,
});

export default useEpigramCommentsQuery;

0 comments on commit 67903f7

Please sign in to comment.