Files
movie-advisor/data/queries/trending.ts
T
ner 09aceccec9 feat(trending): amazon tab, tab group divider and arrow-hover wheel scroll
- Amazon tab for the series trending row (TMDB provider 9, Amazon
  Prime Video US), lazy-loaded like Netflix/HBO
- Nav renders a divider before tabs flagged with 'divider', separating
  the trending group from Similar/Recommendations (no leading divider
  on the show-page preview)
- Vertical wheel now steps the row card-by-card only while hovering the
  prev/next arrow zones: deltas accumulate and a smooth scroll lands on
  the next/previous snap point, so mandatory snap never pulls back.
  Everywhere else the wheel scrolls the page as before
2026-09-24 16:25:35 +03:00

61 lines
1.6 KiB
TypeScript

import movieAdvisor from '../clients/movieAdvisor';
import mapMoviesSeriesResponseToShows from '../dto/Show';
export type TrendingQueryProps = {
type: 'trending' | 'streaming' | 'theater' | 'apple' | 'netflix' | 'hbo' | 'amazon';
enabled?: boolean;
};
const TV_WATCH_PROVIDERS: Partial<Record<TrendingQueryProps['type'], number>> = {
apple: 350,
netflix: 8,
hbo: 1899,
amazon: 9
};
const trendingQuery = ({ type, enabled }: TrendingQueryProps) => ({
enabled,
queryKey: ['trending', `type-${type}`],
initialPageParam: '1',
queryFn: ({ pageParam = '1' }: { pageParam?: string }) => {
const provider = TV_WATCH_PROVIDERS[type];
if (provider) {
return movieAdvisor
.get<TMDBPagination<Series>>('/discover/tv', {
params: {
page: pageParam,
watch_region: 'US',
with_watch_monetization_types: 'flatrate',
with_watch_providers: provider
}
})
.then((response) => mapMoviesSeriesResponseToShows(response, 'tv'));
}
const params: Record<string, string | number> = {
page: pageParam
};
if (type !== 'trending') {
params['watch_region'] = 'US';
}
if (type === 'theater') {
params['with_release_type'] = 3;
}
if (type === 'streaming') {
params['with_watch_monetization_types'] = 'flatrate';
}
return movieAdvisor
.get<TMDBPagination<Movie>>(type === 'trending' ? '/trending/movie/day' : '/discover/movie', {
params
})
.then((response) => mapMoviesSeriesResponseToShows(response));
}
});
export default trendingQuery;