feat(show-type): global movie/series toggle, type-aware pages and search, ?type=tv in URL
This commit is contained in:
1 parent
5b41dbca10
commit
0824090c6d
21 files changed
+415
-174
No files matched your search
@@ -2,14 +2,34 @@ import movieAdvisor from '../clients/movieAdvisor';
|
||||
import mapMoviesSeriesResponseToShows from '../dto/Show';
|
||||
|
||||
export type TrendingQueryProps = {
|
||||
type: 'trending' | 'streaming' | 'theater';
|
||||
type: 'trending' | 'streaming' | 'theater' | 'apple' | 'netflix' | 'hbo';
|
||||
enabled?: boolean;
|
||||
};
|
||||
|
||||
const TV_WATCH_PROVIDERS: Partial<Record<TrendingQueryProps['type'], number>> = {
|
||||
apple: 350,
|
||||
netflix: 8,
|
||||
hbo: 1899
|
||||
};
|
||||
|
||||
const trendingQuery = ({ type, enabled }: TrendingQueryProps) => ({
|
||||
enabled,
|
||||
queryKey: ['trending', `type-${type}`],
|
||||
queryFn: () => {
|
||||
const provider = TV_WATCH_PROVIDERS[type];
|
||||
|
||||
if (provider) {
|
||||
return movieAdvisor
|
||||
.get<TMDBPagination<Series>>('/discover/tv', {
|
||||
params: {
|
||||
watch_region: 'US',
|
||||
with_watch_monetization_types: 'flatrate',
|
||||
with_watch_providers: provider
|
||||
}
|
||||
})
|
||||
.then((response) => mapMoviesSeriesResponseToShows(response, 'tv').results);
|
||||
}
|
||||
|
||||
const params: Record<string, string | number> = {};
|
||||
|
||||
if (type !== 'trending') {
|
||||
|
||||
Reference in new issue
Block a user