refactor: clean code and remove unnecessary dependencies
This commit is contained in:
1 parent
eceae6fec7
commit
ebf599eed6
92 files changed
+1152
-2842
No files matched your search
@@ -1,24 +1,15 @@
|
||||
'use client';
|
||||
|
||||
import { useInfiniteQuery } from '@tanstack/react-query';
|
||||
import { topMovies } from '@/api';
|
||||
import useInfiniteList from '@/hooks/useInfiniteList';
|
||||
|
||||
import { topMovies } from '@/lib/api';
|
||||
|
||||
const useStarring = ({ actorId }: { actorId?: string }) => {
|
||||
return useInfiniteQuery({
|
||||
const useStarring = ({ actorId }: { actorId?: string }) =>
|
||||
useInfiniteList({
|
||||
queryKey: ['starring', actorId],
|
||||
enabled: Boolean(actorId),
|
||||
queryFn: ({ pageParam }) => {
|
||||
return topMovies({ page: pageParam as string, starring: actorId });
|
||||
},
|
||||
getNextPageParam(lastPage) {
|
||||
const { page, total_pages } = lastPage as { page: number; total_pages: number };
|
||||
if (page === total_pages) return undefined;
|
||||
|
||||
return `${page + 1}`;
|
||||
},
|
||||
initialPageParam: '1'
|
||||
queryFn: ({ page }) => {
|
||||
return topMovies({ page, starring: actorId });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export default useStarring;
|
||||
Reference in new issue
Block a user