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,7 +1,8 @@
|
||||
import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
|
||||
import { Metadata } from 'next';
|
||||
|
||||
import { usersShows } from '@/api';
|
||||
import { session } from '@/api';
|
||||
import usersShowsQuery from '@/api/queries/usersShows';
|
||||
import getQueryClient from '@/lib/queryClient';
|
||||
|
||||
import Container from './container';
|
||||
@@ -12,17 +13,13 @@ export const metadata: Metadata = {
|
||||
'View your favorite shows on Movie Advisor. Keep track of films you’ve added and revisit your top picks anytime.'
|
||||
};
|
||||
|
||||
const Favorites = async () => {
|
||||
const Favorites = () => {
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
const list = 'favorite';
|
||||
const showType = 'movie';
|
||||
|
||||
await queryClient.prefetchInfiniteQuery({
|
||||
queryKey: [`users-${list}`, showType],
|
||||
queryFn: () => usersShows({ showType, list, page: '1' }),
|
||||
initialPageParam: '1'
|
||||
});
|
||||
queryClient.prefetchInfiniteQuery(usersShowsQuery({ showType, list, session: session() }));
|
||||
|
||||
return (
|
||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
||||
|
||||
Reference in new issue
Block a user