refactor: clean code and remove unnecessary dependencies

This commit is contained in:
ner committed 2024-09-30 18:54:13 +03:00
1 parent eceae6fec7
commit ebf599eed6
92 files changed
+1152 -2842

No files matched your search

+7 -16
View File
@@ -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;