fix: torrent size
This commit is contained in:
1 parent
8d7e2df869
commit
c6d306cb7b
22 files changed
+1638
-300
No files matched your search
@@ -0,0 +1,20 @@
|
||||
'use client';
|
||||
|
||||
import List from '@/components/Movie/List';
|
||||
|
||||
import usePopular from './usePopular';
|
||||
|
||||
export default function Container() {
|
||||
const { data: top, hasNextPage, fetchNextPage, isFetched } = usePopular();
|
||||
|
||||
return (
|
||||
<>
|
||||
<List pages={top?.pages || []} fetchNextPage={fetchNextPage} hasNextPage={hasNextPage} />
|
||||
{isFetched && !top?.pages?.[0]?.results?.length && (
|
||||
<div className='h-40 w-full flex items-center justify-center text-xl text-muted-foreground'>
|
||||
Nothing was found
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
|
||||
|
||||
import { popularMovies } from '@/lib/api';
|
||||
import getQueryClient from '@/lib/queryClient';
|
||||
|
||||
import Container from './container';
|
||||
|
||||
export default async function Popular() {
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
await queryClient.prefetchInfiniteQuery({
|
||||
queryKey: ['popular'],
|
||||
queryFn: () => popularMovies({}),
|
||||
initialPageParam: '1'
|
||||
});
|
||||
|
||||
return (
|
||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
||||
<Container />
|
||||
</HydrationBoundary>
|
||||
);
|
||||
}
|
||||
|
||||
export const revalidate = 3600;
|
||||
@@ -0,0 +1,23 @@
|
||||
'use client';
|
||||
|
||||
import { useInfiniteQuery } from '@tanstack/react-query';
|
||||
|
||||
import { popularMovies } from '@/lib/api';
|
||||
|
||||
const usePopular = () => {
|
||||
return useInfiniteQuery({
|
||||
queryKey: ['popular'],
|
||||
queryFn: ({ pageParam }) => {
|
||||
return popularMovies({ page: pageParam as string });
|
||||
},
|
||||
getNextPageParam(lastPage) {
|
||||
const { page, total_pages } = lastPage as { page: number; total_pages: number };
|
||||
if (page === total_pages) return undefined;
|
||||
|
||||
return `${page + 1}`;
|
||||
},
|
||||
initialPageParam: '1'
|
||||
});
|
||||
};
|
||||
|
||||
export default usePopular;
|
||||
Reference in new issue
Block a user