export const mapMovieSeriesToShow = ( { id, overview, backdrop_path, poster_path, vote_average, vote_count, ...item }: Movie | Series, type: Show['type'] = 'movie' ): Show => ({ id, type, overview, rating: vote_average, votes: vote_count, backdrop: backdrop_path ? `https://image.tmdb.org/t/p/w1280${backdrop_path}` : '', poster: poster_path ? { '1x': `https://image.tmdb.org/t/p/w342${poster_path}`, '1.5x': `https://image.tmdb.org/t/p/w500${poster_path}`, '2x': `https://image.tmdb.org/t/p/w780${poster_path}` } : { '1x': '', '1.5x': '', '2x': '' }, release: 'release_date' in item ? item.release_date : item.first_air_date, title: 'release_date' in item ? item.title : item.name }); const mapMoviesSeriesResponseToShows = ( { total_pages, page, results }: TMDBPagination | TMDBPagination, type: Show['type'] = 'movie' ): Pagination => ({ page, total: total_pages, results: results .map((show) => mapMovieSeriesToShow(show, type)) .filter((show) => show.votes && show.release && show.backdrop && show.poster) }); export default mapMoviesSeriesResponseToShows;