'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 = ({ personId }) => { const { data: profile, isError } = useProfile({ personId }); useTrackOnce(analytics.personViewed, profile ? personId : undefined, () => ({ personId, personName: profile!.name })); if (isError) return ; if (!profile) return ; const dates = lifespan(profile); return (
{Boolean(profile.photo) && (
{profile.name}
)}

{profile.name}

{Boolean(profile.department) && {profile.department}} {Boolean(dates) && {dates}} {Boolean(profile.birthplace) && {profile.birthplace}}
{Boolean(profile.shows.length) && (

Filmography

)} {!profile.shows.length && }
); }; export default Person;