diff --git a/react_frontend/src/lib/media-utils.ts b/react_frontend/src/lib/media-utils.ts
index 1d75771..9d10c9e 100644
--- a/react_frontend/src/lib/media-utils.ts
+++ b/react_frontend/src/lib/media-utils.ts
@@ -137,3 +137,24 @@ export function getYear(dateStr: string | null): string {
if (!dateStr) return "";
return new Date(dateStr).getFullYear().toString();
}
+
+export function calculateAge(
+ birthday: string | null | undefined,
+ deathday?: string | null,
+): number | null {
+ if (!birthday) return null;
+
+ const birth = new Date(birthday);
+ if (isNaN(birth.getTime())) return null;
+
+ let end = deathday ? new Date(deathday) : new Date();
+ if (deathday && isNaN(end.getTime())) end = new Date();
+
+ let age = end.getFullYear() - birth.getFullYear();
+ const monthDiff = end.getMonth() - birth.getMonth();
+ if (monthDiff < 0 || (monthDiff === 0 && end.getDate() < birth.getDate())) {
+ age--;
+ }
+
+ return age;
+}
diff --git a/react_frontend/src/pages/PeoplePage.tsx b/react_frontend/src/pages/PeoplePage.tsx
index a7035c8..03b18af 100644
--- a/react_frontend/src/pages/PeoplePage.tsx
+++ b/react_frontend/src/pages/PeoplePage.tsx
@@ -8,8 +8,13 @@ import { Skeleton } from "@/components/ui/skeleton";
import { Switch } from "@/components/ui/switch";
import { Label } from "@/components/ui/label";
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from "@/components/ui/tooltip";
import { Search, Heart } from "lucide-react";
-import { getProfileUrl } from "@/lib/media-utils";
+import { getProfileUrl, formatDate, calculateAge } from "@/lib/media-utils";
type PeopleFilter = "all" | "favorite";
@@ -207,6 +212,18 @@ export function PeoplePage() {
{person.name}
+ {person.birthday && (
+
+ }>
+
+ Born: {formatDate(person.birthday)}
+
+
+
+ Age: {calculateAge(person.birthday, person.deathday)}
+
+
+ )}
))}
diff --git a/react_frontend/src/pages/PersonDetailsPage.tsx b/react_frontend/src/pages/PersonDetailsPage.tsx
index 11257e1..92501aa 100644
--- a/react_frontend/src/pages/PersonDetailsPage.tsx
+++ b/react_frontend/src/pages/PersonDetailsPage.tsx
@@ -1,4 +1,4 @@
-import { useParams, useNavigate, useLocation } from "react-router-dom";
+import { useParams, useNavigate } from "react-router-dom";
import { useState, useEffect } from "react";
import {
usePerson,
@@ -13,8 +13,14 @@ import { Skeleton } from "@/components/ui/skeleton";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import { Separator } from "@/components/ui/separator";
import { Button } from "@/components/ui/button";
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from "@/components/ui/tooltip";
import { EntryCard } from "@/components/entries/EntryCard";
-import { getProfileUrl, formatDate } from "@/lib/media-utils";
+import { getTmdbImageUrl } from "@/lib/api";
+import { formatDate, calculateAge } from "@/lib/media-utils";
import {
ChevronLeft,
ChevronRight,
@@ -24,58 +30,131 @@ import {
ExternalLink,
} from "lucide-react";
import type { TmdbEntry } from "@/types";
-import type { TmdbFilmographyItem } from "@/api/people";
+import type {
+ TmdbFilmographyItem,
+ TmdbFilmographyResponse,
+} from "@/api/people";
-const TMDB_IMG = "https://image.tmdb.org/t/p";
-
-export function PersonDetailsPage() {
- const { id, tmdbId } = useParams<{ id?: string; tmdbId?: string }>();
- const location = useLocation();
- const isTmdbMode = location.pathname.startsWith("/people/tmdb/");
-
- if (isTmdbMode && tmdbId) {
- return ;
- }
-
- return ;
+/** Person data normalized from either the local DB or a TMDB preview. */
+interface PersonProfile {
+ name: string;
+ biography: string | null;
+ birthday: string | null;
+ deathday: string | null;
+ place_of_birth: string | null;
+ profile_path: string | null;
+ known_for_department: string | null;
+ tmdb_id: number | null;
+ favorite: boolean;
}
-/* ─── Local DB person ─── */
-
-function LocalPersonView({ personId }: { personId: number }) {
+/**
+ * Person page for both sources:
+ * - `/people/:id`: the person is in the local DB, so details come from there
+ * and the filmography from TMDB via the local id.
+ * - `/people/tmdb/:tmdbId`: the person is not in the local DB, so everything
+ * comes from the TMDB preview. If the preview reports a local id, redirect.
+ */
+export function PersonDetailsPage() {
+ const { id, tmdbId } = useParams<{ id?: string; tmdbId?: string }>();
const navigate = useNavigate();
- const { data: person, isLoading, isError } = usePerson(personId);
- const { data: tmdbFilmography, isLoading: tmdbLoading } =
- usePersonTmdbFilmography(personId);
+ const localId = id ? parseInt(id, 10) : 0;
+ const isLocal = !!localId;
+ const tmdbIdNum = !isLocal && tmdbId ? parseInt(tmdbId, 10) : 0;
+
+ // Queries are disabled when their id is 0, so only one source is fetched.
+ const localPerson = usePerson(localId);
+ const localFilmography = usePersonTmdbFilmography(localId);
+ const tmdbPreview = useTmdbPersonPreview(tmdbIdNum);
+
const updatePerson = useUpdatePerson();
+ const fetchPerson = useFetchPersonByTmdbId();
useLibrary();
const libraryMap = useLibraryStore((s) => s.entries);
const libraryLoaded = useLibraryStore((s) => s.isLoaded);
+ const existingLocalId = tmdbPreview.data?.local_id;
+ useEffect(() => {
+ if (existingLocalId) {
+ navigate(`/people/${existingLocalId}`, { replace: true });
+ }
+ }, [existingLocalId, navigate]);
+
+ const isError = isLocal ? localPerson.isError : tmdbPreview.isError;
+
if (isError) {
return (
Person not found
- This person could not be loaded. They may not exist in the database.
+ {isLocal
+ ? "This person could not be loaded. They may not exist in the database."
+ : "Could not load person data from TMDB."}