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 { similarShows } from '@/api';
|
||||
import similarQuery from '@/api/queries/similar';
|
||||
import getQueryClient from '@/lib/queryClient';
|
||||
|
||||
import Container from './container';
|
||||
@@ -10,11 +10,7 @@ const Similar = ({ searchParams }: { searchParams: Record<string, string> }) =>
|
||||
|
||||
const { id, type } = searchParams || {};
|
||||
|
||||
queryClient.prefetchInfiniteQuery({
|
||||
queryKey: ['similar', id, type],
|
||||
queryFn: () => similarShows({ showId: id, showType: type as Show['type'] }),
|
||||
initialPageParam: '1'
|
||||
});
|
||||
queryClient.prefetchInfiniteQuery(similarQuery({ showId: id, showType: type as Show['type'] }));
|
||||
|
||||
return (
|
||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { similarShows } from '@/api';
|
||||
import similarQuery from '@/api/queries/similar';
|
||||
import useInfiniteList from '@/hooks/useInfiniteList';
|
||||
|
||||
interface Props {
|
||||
@@ -8,12 +8,6 @@ interface Props {
|
||||
showType: Show['type'];
|
||||
}
|
||||
|
||||
const useSimilar = ({ showId, showType = 'movie' }: Props) =>
|
||||
useInfiniteList({
|
||||
suspense: true,
|
||||
enabled: Boolean(showId),
|
||||
queryKey: ['similar', showId, showType],
|
||||
queryFn: ({ page }) => similarShows({ page, showId, showType })
|
||||
});
|
||||
const useSimilar = ({ showId, showType = 'movie' }: Props) => useInfiniteList(similarQuery({ showId, showType }));
|
||||
|
||||
export default useSimilar;
|
||||
Reference in new issue
Block a user