refactoring: server actions data fetching -> api routes
This commit is contained in:
1 parent
1111712d2c
commit
5cbf93b3b8
38 files changed
+326
-308
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
|
||||
|
||||
import { topMovies } from '@/api';
|
||||
import popularQuery from '@/api/queries/popular';
|
||||
import getQueryClient from '@/lib/queryClient';
|
||||
|
||||
import Container from './container';
|
||||
@@ -10,11 +10,7 @@ const Starring = ({ searchParams }: { searchParams: Record<string, string> }) =>
|
||||
|
||||
const { actorId } = searchParams || {};
|
||||
|
||||
queryClient.prefetchInfiniteQuery({
|
||||
queryKey: ['starring', actorId],
|
||||
queryFn: () => topMovies({ starring: actorId }),
|
||||
initialPageParam: '1'
|
||||
});
|
||||
queryClient.prefetchInfiniteQuery(popularQuery({ sortBy: 'vote_average.desc', starring: actorId }));
|
||||
|
||||
return (
|
||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
'use client';
|
||||
|
||||
import { topMovies } from '@/api';
|
||||
import popularQuery from '@/api/queries/popular';
|
||||
import useInfiniteList from '@/hooks/useInfiniteList';
|
||||
|
||||
const useStarring = ({ actorId }: { actorId?: string }) =>
|
||||
useInfiniteList({
|
||||
suspense: true,
|
||||
queryKey: ['starring', actorId],
|
||||
enabled: Boolean(actorId),
|
||||
queryFn: ({ page }) => topMovies({ page, starring: actorId })
|
||||
});
|
||||
useInfiniteList(popularQuery({ sortBy: 'vote_average.desc', starring: actorId }));
|
||||
|
||||
export default useStarring;
|
||||
Reference in new issue
Block a user