feat: show page

This commit is contained in:
ner committed 2024-11-06 22:12:19 +02:00
1 parent abe1c795a1
commit 183c7231a1
26 files changed
+210 -176

No files matched your search

+1
View File
@@ -13,6 +13,7 @@ const detailsQuery = ({ showId, showType }: DetailsQueryProps) => ({
movieAdvisor
.get<(Movie | Series) & Details>(`/${showType}/${showId}`)
.then((response) => ({ ...response, ...mapMovieSeriesToShow(response, showType) }))
.catch((error) => Promise.reject(error))
});
export default detailsQuery;
+8 -8
View File
@@ -2,21 +2,21 @@ import movieAdvisor from '../clients/movieAdvisor';
import mapMoviesSeriesResponseToShows from '../dto/Show';
export type SimilarQueryProps = {
showId: string;
showId: Show['id'];
showType: Show['type'];
type?: 'similar' | 'recommendations';
};
const similarQuery = ({ showId, showType }: SimilarQueryProps) => ({
queryKey: ['similar', showId, showType],
initialPageParam: '1',
queryFn: ({ pageParam = '1' }: { pageParam?: string }) =>
const similarQuery = ({ showId, showType, type }: SimilarQueryProps) => ({
queryKey: [type, showId, showType],
queryFn: () =>
movieAdvisor
.get<TMDBPagination<Movie> | TMDBPagination<Series>>(`/${showType}/${showId}/recommendations`, {
.get<TMDBPagination<Movie> | TMDBPagination<Series>>(`/${showType}/${showId}/${type}`, {
params: {
page: pageParam
page: 1
}
})
.then((response) => mapMoviesSeriesResponseToShows(response, showType))
.then((response) => mapMoviesSeriesResponseToShows(response, showType).results)
});
export default similarQuery;
+3 -1
View File
@@ -3,9 +3,11 @@ import mapMoviesSeriesResponseToShows from '../dto/Show';
export type TrendingQueryProps = {
type: 'trending' | 'streaming' | 'theater';
enabled?: boolean;
};
const trendingQuery = ({ type }: TrendingQueryProps) => ({
const trendingQuery = ({ type, enabled }: TrendingQueryProps) => ({
enabled,
queryKey: ['trending', `type-${type}`],
queryFn: () => {
const params: Record<string, string | number> = {};