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,13 +1,7 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
|
||||
import { popularByType, trendingMovies } from '@/api';
|
||||
import trendingQuery, { TrendingQueryProps } from '@/api/queries/trending';
|
||||
|
||||
const useTrending = ({ type, enabled }: { enabled?: boolean; type: 'trending' | 'streaming' | 'theater' | 'rent' }) => {
|
||||
return useQuery({
|
||||
enabled,
|
||||
queryKey: ['trending', type],
|
||||
queryFn: () => (type === 'trending' ? trendingMovies() : popularByType({ type }))
|
||||
});
|
||||
};
|
||||
const useTrending = ({ type }: TrendingQueryProps) => useQuery(trendingQuery({ type }));
|
||||
|
||||
export default useTrending;
|
||||
Reference in new issue
Block a user