You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
814 B
33 lines
814 B
import type { TmdbCollection } from '../api/themoviedb/interfaces';
|
|
import { MediaType } from '../constants/media';
|
|
import Media from '../entity/Media';
|
|
import { mapMovieResult, MovieResult } from './Search';
|
|
|
|
export interface Collection {
|
|
id: number;
|
|
name: string;
|
|
overview?: string;
|
|
posterPath?: string;
|
|
backdropPath?: string;
|
|
parts: MovieResult[];
|
|
}
|
|
|
|
export const mapCollection = (
|
|
collection: TmdbCollection,
|
|
media: Media[]
|
|
): Collection => ({
|
|
id: collection.id,
|
|
name: collection.name,
|
|
overview: collection.overview,
|
|
posterPath: collection.poster_path,
|
|
backdropPath: collection.backdrop_path,
|
|
parts: collection.parts.map((part) =>
|
|
mapMovieResult(
|
|
part,
|
|
media?.find(
|
|
(req) => req.tmdbId === part.id && req.mediaType === MediaType.MOVIE
|
|
)
|
|
)
|
|
),
|
|
});
|