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

+15
View File
@@ -0,0 +1,15 @@
import movieAdvisor from '../clients/movieAdvisor';
import mapMoviesSeriesResponseToShows from '../dto/Show';
export type SearchQueryProps = { query: string; type: Show['type'] };
const searchQuery = ({ query, type }: SearchQueryProps) => ({
queryKey: ['search', query, type],
queryFn: ({ pageParam }: { pageParam: string }) =>
movieAdvisor
.get<TMDBPagination<Movie>>(`/search/${type}`, { params: { page: pageParam, query } })
.then((response) => mapMoviesSeriesResponseToShows(response, type)),
enabled: Boolean(query)
});
export default searchQuery;