refactoring: server actions data fetching -> api routes

This commit is contained in:
ner committed 2024-10-26 21:33:39 +03:00
1 parent 1111712d2c
commit 5cbf93b3b8
38 files changed
+326 -308

No files matched your search

+4 -7
View File
@@ -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 WatchList = async () => {
const WatchList = () => {
const queryClient = getQueryClient();
const list = 'watchlist';
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)}>