diff --git a/src/lib/apis/tmdb/tmdb-api.ts b/src/lib/apis/tmdb/tmdb-api.ts index ad4108a..315e677 100644 --- a/src/lib/apis/tmdb/tmdb-api.ts +++ b/src/lib/apis/tmdb/tmdb-api.ts @@ -242,6 +242,34 @@ export class TmdbApi implements Api { }) .then((res) => res.data?.results || []) || Promise.resolve([]); + getPerson = async (person_id: number) => + this.getClient() + .GET('/3/person/{person_id}', { + params: { + path: { + person_id: person_id + }, + query: { + append_to_response: 'images,movie_credits,tv_credits,external_ids' + } + } + }) + .then((res) => res.data as TmdbPersonFull); + + getPersonTaggedImages = async (person_id: number) => + this.getClient() + ?.GET('/3/person/{person_id}/tagged_images', { + params: { + path: { + person_id: person_id + } + } + }) + .then((res) => res.data?.results || []) || Promise.resolve([]); + + getPersonBackdrops = async (person_id: number) => + this.getPersonTaggedImages(person_id).then((r) => r.filter((i) => (i.aspect_ratio || 0) > 1.5)); + // OTHER // USER diff --git a/src/lib/components/DetachedPage/DetachedPage.svelte b/src/lib/components/DetachedPage/DetachedPage.svelte index 02984cb..4b25321 100644 --- a/src/lib/components/DetachedPage/DetachedPage.svelte +++ b/src/lib/components/DetachedPage/DetachedPage.svelte @@ -40,7 +40,7 @@ { - // if (openInModal) { - // openTitleModal({ type, id: tmdbId, provider: 'tmdb' }); - // } else { - // window.location.href = `/${type}/${tmdbId}`; - // } + on:clickOrSelect={() => { + if (tmdbId) navigate(`/person/${tmdbId}`); }} on:enter bind:hasFocus + focusOnClick > diff --git a/src/lib/components/PersonCard/TmdbPersonCard.svelte b/src/lib/components/PersonCard/TmdbPersonCard.svelte index 79aef90..eb1bba4 100644 --- a/src/lib/components/PersonCard/TmdbPersonCard.svelte +++ b/src/lib/components/PersonCard/TmdbPersonCard.svelte @@ -14,7 +14,7 @@ + import { TMDB_POSTER_SMALL } from '../constants.js'; + import { tmdbApi } from '../apis/tmdb/tmdb-api'; + import DetachedPage from '../components/DetachedPage/DetachedPage.svelte'; + import classNames from 'classnames'; + import { DotFilled } from 'radix-icons-svelte'; + import CardGrid from '../components/CardGrid.svelte'; + import TmdbCard from '../components/Card/TmdbCard.svelte'; + import Container from '../../Container.svelte'; + import { scrollIntoView } from '../selectable'; + + export let id: string; + $: person = tmdbApi.getPerson(Number(id)); + $: titles = person.then((person) => { + if (person.known_for_department === 'Acting') { + return [...(person.movie_credits.cast || []), ...(person.tv_credits.cast || [])].sort( + (a, b) => + // @ts-ignore + (b.release_date ?? b.first_air_date ?? 0) > (a.release_date ?? a.first_air_date ?? 0) + ? 1 + : -1 + ); + } else { + return [...(person.movie_credits.crew || []), ...(person.tv_credits.crew || [])].sort( + (a, b) => + // @ts-ignore + (b.release_date ?? b.first_air_date ?? 0) > (a.release_date ?? a.first_air_date ?? 0) + ? 1 + : -1 + ); + } + }); + + + + {#await person then person} + +
+
+ +
+
= 15 + } + )} + > + {person.name} +
+
+

+ Born {new Date(person.birthday || 0).toLocaleDateString('en-US', { + year: 'numeric', + month: 'long', + day: 'numeric' + })} +

+ + +

+ + {(person.movie_credits.cast?.length || 0) + (person.tv_credits.cast?.length || 0)} Credits +

+
+
+ {person.biography} +
+
+
+ + + {#await titles then titles} + {#each titles as title} + + {/each} + {/await} + + + {/await} +