feat(frontend): navigate non-library entries to TMDB preview page

- Add TmdbPreviewPage showing TMDB details without adding to library
- Display backdrop, poster, title, tagline, genres, rating, storyline
- Show season/episode count for TV series
- Add "Add to Library" button that creates entry then redirects to details page
- Show "Already in Library — View" if entry exists in DB
- Add /entry/tmdb/:type/:tmdbId route in router.tsx
- Add TmdbPreview type, entriesApi.previewTmdb(), and useTmdbPreview() hook
- Update EntryCard to navigate to preview page instead of auto-adding

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Mohammed AbadandCopilot committed 2026-04-27 04:03:21 +01:00
1 parent 25b645a16f
commit 02cdcf733d
18 files changed
+949 -204

No files matched your search

+32 -5
View File
@@ -1,6 +1,6 @@
import { useParams } from 'react-router-dom';
import { useParams, useNavigate } from 'react-router-dom';
import { useState } from 'react';
import { usePerson, usePersonTmdbFilmography } from '@/hooks/usePeople';
import { usePerson, usePersonTmdbFilmography, useUpdatePerson } from '@/hooks/usePeople';
import { useLibrary } from '@/hooks/useEntries';
import { useLibraryStore } from '@/stores/useLibraryStore';
import { Skeleton } from '@/components/ui/skeleton';
@@ -9,19 +9,35 @@ import { Separator } from '@/components/ui/separator';
import { Button } from '@/components/ui/button';
import { EntryCard } from '@/components/entries/EntryCard';
import { getProfileUrl, formatDate } from '@/lib/media-utils';
import { ChevronLeft, ChevronRight } from 'lucide-react';
import { ChevronLeft, ChevronRight, Heart } from 'lucide-react';
import type { TmdbEntry } from '@/types';
import type { TmdbFilmographyItem } from '@/api/people';
export function PersonDetailsPage() {
const { id } = useParams<{ id: string }>();
const personId = parseInt(id!, 10);
const { data: person, isLoading } = usePerson(personId);
const navigate = useNavigate();
const { data: person, isLoading, isError } = usePerson(personId);
const { data: tmdbFilmography, isLoading: tmdbLoading } = usePersonTmdbFilmography(personId);
const updatePerson = useUpdatePerson();
useLibrary();
const libraryMap = useLibraryStore((s) => s.entries);
const libraryLoaded = useLibraryStore((s) => s.isLoaded);
if (isError) {
return (
<div className="flex flex-col items-center justify-center gap-3 py-20">
<p className="text-lg font-semibold">Person not found</p>
<p className="text-sm text-muted-foreground">
This person could not be loaded. They may not exist in the database.
</p>
<Button variant="outline" onClick={() => navigate('/people')}>
Back to People
</Button>
</div>
);
}
if (isLoading || !person) {
return (
<div className="space-y-6">
@@ -47,7 +63,18 @@ export function PersonDetailsPage() {
</AvatarFallback>
</Avatar>
<div className="space-y-2 text-center sm:text-left sm:space-y-3">
<h1 className="text-2xl font-bold sm:text-3xl">{person.name}</h1>
<div className="flex items-center gap-2 justify-center sm:justify-start">
<h1 className="text-2xl font-bold sm:text-3xl">{person.name}</h1>
<Button
variant="ghost"
size="icon"
className="h-8 w-8 shrink-0"
onClick={() => updatePerson.mutate({ id: person.id, data: { favorite: !person.favorite } })}
disabled={updatePerson.isPending}
>
<Heart className={`h-5 w-5 ${person.favorite ? 'fill-red-500 text-red-500' : 'text-muted-foreground'}`} />
</Button>
</div>
<div className="flex flex-wrap items-center justify-center gap-2 text-sm text-muted-foreground sm:justify-start sm:gap-3">
{person.known_for_department && <span>{person.known_for_department}</span>}
{person.birthday && (<><span>•</span><span>Born: {formatDate(person.birthday)}</span></>)}