Bare ids are unreadable in the dashboard, so every event that points at a show or a person now carries its title or name. Ids stay for disambiguation, since titles collide across remakes. - ShowRef gains showTitle, so show_viewed, library_toggled, torrents_searched, torrent_selected, playback_started and playback_failed all report it - person_viewed sends personName - random_shuffled sends the title of the movie scrolled to - torrent_selected sends the torrent title next to the show title - subtitles_selected sends the track label, such as English, rather than the internal track value Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
73 lines
2.2 KiB
TypeScript
73 lines
2.2 KiB
TypeScript
'use client';
|
|
|
|
import { FC } from 'react';
|
|
|
|
import List from '@/components/List';
|
|
import NoResults from '@/components/NoResults';
|
|
import analytics from '@/lib/analytics';
|
|
import useTrackOnce from '@/lib/analytics/useTrackOnce';
|
|
import { formatDate } from '@/lib/utils';
|
|
|
|
import Biography from './components/Biography';
|
|
import PersonSkeleton from './components/Skeleton';
|
|
import useProfile from './useProfile';
|
|
|
|
interface Props {
|
|
personId: string;
|
|
}
|
|
|
|
const lifespan = ({ birthday, deathday }: Profile) => {
|
|
if (!birthday) return '';
|
|
|
|
return deathday ? `${formatDate(birthday)} — ${formatDate(deathday)}` : formatDate(birthday);
|
|
};
|
|
|
|
const Person: FC<Props> = ({ personId }) => {
|
|
const { data: profile, isError } = useProfile({ personId });
|
|
|
|
useTrackOnce(analytics.personViewed, profile ? personId : undefined, () => ({
|
|
personId,
|
|
personName: profile!.name
|
|
}));
|
|
|
|
if (isError) return <NoResults />;
|
|
|
|
if (!profile) return <PersonSkeleton />;
|
|
|
|
const dates = lifespan(profile);
|
|
|
|
return (
|
|
<div className='flex flex-1 flex-col'>
|
|
<div className='flex flex-col gap-2 md:flex-row'>
|
|
{Boolean(profile.photo) && (
|
|
<div className='card-aspect-ratio static-aspect-ratio relative mx-auto overflow-hidden rounded-lg bg-black'>
|
|
<img className='size-full object-cover' src={profile.photo} alt={profile.name} />
|
|
</div>
|
|
)}
|
|
<div className='flex grow flex-col bg-background'>
|
|
<h1 className='mb-4 text-3xl'>{profile.name}</h1>
|
|
|
|
<div className='mb-4 flex w-full flex-wrap gap-5 whitespace-nowrap text-sm'>
|
|
{Boolean(profile.department) && <span>{profile.department}</span>}
|
|
{Boolean(dates) && <span>{dates}</span>}
|
|
{Boolean(profile.birthplace) && <span className='whitespace-normal'>{profile.birthplace}</span>}
|
|
</div>
|
|
|
|
<Biography text={profile.biography} />
|
|
</div>
|
|
</div>
|
|
|
|
{Boolean(profile.shows.length) && (
|
|
<div className='mt-5'>
|
|
<h2 className='mb-3 inline-block text-lg'>Filmography</h2>
|
|
<List shows={profile.shows} />
|
|
</div>
|
|
)}
|
|
|
|
{!profile.shows.length && <NoResults />}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default Person;
|