refactor: move genre/studio/network calls into their own endpoints
this commit also adds a `useDiscover` hook to help with creating discover pages with less repeating code
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type {
|
||||
TmdbMovieDetails,
|
||||
TmdbMovieReleaseResult,
|
||||
TmdbProductionCompany,
|
||||
} from '../api/themoviedb/interfaces';
|
||||
import {
|
||||
ProductionCompany,
|
||||
@@ -79,6 +80,18 @@ export interface MovieDetails {
|
||||
plexUrl?: string;
|
||||
}
|
||||
|
||||
export const mapProductionCompany = (
|
||||
company: TmdbProductionCompany
|
||||
): ProductionCompany => ({
|
||||
id: company.id,
|
||||
name: company.name,
|
||||
originCountry: company.origin_country,
|
||||
description: company.description,
|
||||
headquarters: company.headquarters,
|
||||
homepage: company.homepage,
|
||||
logoPath: company.logo_path,
|
||||
});
|
||||
|
||||
export const mapMovieDetails = (
|
||||
movie: TmdbMovieDetails,
|
||||
media?: Media
|
||||
@@ -91,12 +104,7 @@ export const mapMovieDetails = (
|
||||
originalLanguage: movie.original_language,
|
||||
originalTitle: movie.original_title,
|
||||
popularity: movie.popularity,
|
||||
productionCompanies: movie.production_companies.map((company) => ({
|
||||
id: company.id,
|
||||
logoPath: company.logo_path,
|
||||
originCountry: company.origin_country,
|
||||
name: company.name,
|
||||
})),
|
||||
productionCompanies: movie.production_companies.map(mapProductionCompany),
|
||||
productionCountries: movie.production_countries,
|
||||
releaseDate: movie.release_date,
|
||||
releases: movie.release_dates,
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
mapExternalIds,
|
||||
Keyword,
|
||||
mapVideos,
|
||||
TvNetwork,
|
||||
} from './common';
|
||||
import type {
|
||||
TmdbTvEpisodeResult,
|
||||
@@ -16,6 +17,7 @@ import type {
|
||||
TmdbTvDetails,
|
||||
TmdbSeasonWithEpisodes,
|
||||
TmdbTvRatingResult,
|
||||
TmdbNetwork,
|
||||
} from '../api/themoviedb/interfaces';
|
||||
import type Media from '../entity/Media';
|
||||
import { Video } from './Movie';
|
||||
@@ -77,7 +79,7 @@ export interface TvDetails {
|
||||
lastEpisodeToAir?: Episode;
|
||||
name: string;
|
||||
nextEpisodeToAir?: Episode;
|
||||
networks: ProductionCompany[];
|
||||
networks: TvNetwork[];
|
||||
numberOfEpisodes: number;
|
||||
numberOfSeasons: number;
|
||||
originCountry: string[];
|
||||
@@ -139,6 +141,15 @@ export const mapSeasonWithEpisodes = (
|
||||
posterPath: season.poster_path,
|
||||
});
|
||||
|
||||
export const mapNetwork = (network: TmdbNetwork): TvNetwork => ({
|
||||
id: network.id,
|
||||
name: network.name,
|
||||
originCountry: network.origin_country,
|
||||
headquarters: network.headquarters,
|
||||
homepage: network.homepage,
|
||||
logoPath: network.logo_path,
|
||||
});
|
||||
|
||||
export const mapTvDetails = (
|
||||
show: TmdbTvDetails,
|
||||
media?: Media
|
||||
@@ -157,12 +168,7 @@ export const mapTvDetails = (
|
||||
languages: show.languages,
|
||||
lastAirDate: show.last_air_date,
|
||||
name: show.name,
|
||||
networks: show.networks.map((network) => ({
|
||||
id: network.id,
|
||||
name: network.name,
|
||||
originCountry: network.origin_country,
|
||||
logoPath: network.logo_path,
|
||||
})),
|
||||
networks: show.networks.map(mapNetwork),
|
||||
numberOfEpisodes: show.number_of_episodes,
|
||||
numberOfSeasons: show.number_of_seasons,
|
||||
originCountry: show.origin_country,
|
||||
|
||||
@@ -14,6 +14,18 @@ export interface ProductionCompany {
|
||||
logoPath?: string;
|
||||
originCountry: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
headquarters?: string;
|
||||
homepage?: string;
|
||||
}
|
||||
|
||||
export interface TvNetwork {
|
||||
id: number;
|
||||
logoPath?: string;
|
||||
originCountry?: string;
|
||||
name: string;
|
||||
headquarters?: string;
|
||||
homepage?: string;
|
||||
}
|
||||
|
||||
export interface Keyword {
|
||||
|
||||
Reference in New Issue
Block a user