feat(frontend): Entry details redesign, people filmography, calendar improvements
- EntryDetailsPage: sticky poster layout, centered max-w-4xl, director by-line with link, rating pills (IMDb/TMDB/You), quick actions under poster, RatingDialog with star UI, In Collections section using backdrops, EntrySettingsDialog with show_in_calendar / auto_sync / rating options - RatingDialog: new component with 10-star interactive rating - AddEntryToCollectionDialog: optimistic cache updates so checkbox state reflects immediately and In Collections section on entry details page refreshes - PersonDetailsPage: filmography section showing library vs. non-library entries via person.roles, TMDB combined credits for non-library titles - PersonTmdbRedirectPage: new redirect page for TMDB person IDs to local person ID - PeoplePage: fix person card links to use /people/tmdb/:tmdbId - CalendarPage: full-height layout, larger episode thumbnails, episode items clickable, improved tooltip, show_in_calendar backend filter - Fix useUpdateEntry to also invalidate entryKeys.all (favorite button reactivity) - Fix updateRatings API body wrapping - Add useUpdateEntryRatings, usePersonCredits, useFetchPersonByTmdbId hooks - Add getCollectionBackdropUrl to media-utils - Types: show_in_calendar, auto_sync on Entry; id on EntryRatings; roles on People - Backend: fix fetchPersonData alias in peopleService; remove duplicate getPersonCredits; add show_in_calendar filter to episodeService
This commit is contained in:
1 parent
11eab03987
commit
3ca24434d7
16 files changed
+857
-322
No files matched your search
@@ -1,10 +1,12 @@
|
||||
import { useState, useMemo } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { format, startOfMonth, endOfMonth, eachDayOfInterval, getDay, addMonths, subMonths, isSameDay } from 'date-fns';
|
||||
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { useEpisodesByMonth } from '@/hooks/useEpisodes';
|
||||
import { getTmdbPosterUrl } from '@/lib/media-utils';
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
|
||||
import { getTmdbPosterUrl, getPosterUrl } from '@/lib/media-utils';
|
||||
import { Tooltip, TooltipContent, TooltipTrigger, TooltipProvider } from '@/components/ui/tooltip';
|
||||
import type { Episode } from '@/types';
|
||||
|
||||
const DAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
||||
|
||||
@@ -35,8 +37,8 @@ export function CalendarPage() {
|
||||
}, [episodes]);
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex flex-col h-[calc(100vh-7rem)]">
|
||||
<div className="flex items-center justify-between mb-4 shrink-0">
|
||||
<h1 className="text-2xl font-bold">Calendar</h1>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
@@ -46,7 +48,7 @@ export function CalendarPage() {
|
||||
>
|
||||
<ChevronLeft className="h-4 w-4" />
|
||||
</Button>
|
||||
<span className="min-w-[140px] text-center font-medium">
|
||||
<span className="min-w-35 text-center font-medium">
|
||||
{format(currentDate, 'MMMM yyyy')}
|
||||
</span>
|
||||
<Button
|
||||
@@ -59,81 +61,134 @@ export function CalendarPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Calendar Grid */}
|
||||
<div className="rounded-lg border border-border overflow-hidden">
|
||||
{/* Day headers */}
|
||||
<div className="grid grid-cols-7 bg-muted/50">
|
||||
{DAYS.map((day) => (
|
||||
<div key={day} className="px-2 py-2 text-center text-xs font-medium text-muted-foreground">
|
||||
{day}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
{/* Calendar Grid — fills remaining height */}
|
||||
<TooltipProvider>
|
||||
<div className="flex flex-col flex-1 rounded-lg border border-border overflow-hidden min-h-0">
|
||||
{/* Day headers */}
|
||||
<div className="grid grid-cols-7 bg-muted/50 shrink-0">
|
||||
{DAYS.map((day) => (
|
||||
<div key={day} className="px-2 py-2 text-center text-xs font-medium text-muted-foreground">
|
||||
{day}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Day cells */}
|
||||
<div className="grid grid-cols-7">
|
||||
{/* Empty cells for offset */}
|
||||
{Array.from({ length: startDayOfWeek }).map((_, i) => (
|
||||
<div key={`empty-${i}`} className="min-h-24 border-t border-r border-border bg-muted/20" />
|
||||
))}
|
||||
{/* Day cells */}
|
||||
<div className="grid grid-cols-7 flex-1 overflow-y-auto">
|
||||
{/* Empty cells for offset */}
|
||||
{Array.from({ length: startDayOfWeek }).map((_, i) => (
|
||||
<div key={`empty-${i}`} className="border-t border-r border-border bg-muted/20" />
|
||||
))}
|
||||
|
||||
{days.map((day) => {
|
||||
const key = format(day, 'yyyy-MM-dd');
|
||||
const dayEpisodes = episodesByDate.get(key) || [];
|
||||
const isToday = isSameDay(day, new Date());
|
||||
{days.map((day) => {
|
||||
const key = format(day, 'yyyy-MM-dd');
|
||||
const dayEpisodes = episodesByDate.get(key) || [];
|
||||
const isToday = isSameDay(day, new Date());
|
||||
|
||||
return (
|
||||
<div
|
||||
key={key}
|
||||
className={`min-h-24 border-t border-r border-border p-1 ${
|
||||
isToday ? 'bg-primary/5' : ''
|
||||
}`}
|
||||
>
|
||||
<span
|
||||
className={`inline-flex h-6 w-6 items-center justify-center rounded-full text-xs ${
|
||||
isToday
|
||||
? 'bg-primary text-primary-foreground font-bold'
|
||||
: 'text-muted-foreground'
|
||||
return (
|
||||
<div
|
||||
key={key}
|
||||
className={`border-t border-r border-border p-1.5 ${
|
||||
isToday ? 'bg-primary/5' : ''
|
||||
}`}
|
||||
>
|
||||
{format(day, 'd')}
|
||||
</span>
|
||||
<div className="mt-1 space-y-0.5">
|
||||
{dayEpisodes.slice(0, 3).map((ep) => (
|
||||
<Tooltip key={ep.id}>
|
||||
<TooltipTrigger asChild>
|
||||
<div className="flex items-center gap-1 rounded bg-accent/50 px-1 py-0.5">
|
||||
{ep.still_path && (
|
||||
<img
|
||||
src={getTmdbPosterUrl(ep.still_path, 'w92')}
|
||||
alt=""
|
||||
className="h-4 w-6 rounded object-cover"
|
||||
/>
|
||||
)}
|
||||
<span className="text-[10px] truncate">
|
||||
S{ep.season_id} E{ep.episode_number}
|
||||
</span>
|
||||
</div>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<p className="text-xs font-medium">{ep.name}</p>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Episode {ep.episode_number}
|
||||
</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
))}
|
||||
{dayEpisodes.length > 3 && (
|
||||
<span className="text-[10px] text-muted-foreground pl-1">
|
||||
+{dayEpisodes.length - 3} more
|
||||
</span>
|
||||
)}
|
||||
<span
|
||||
className={`inline-flex h-6 w-6 items-center justify-center rounded-full text-xs mb-1 ${
|
||||
isToday
|
||||
? 'bg-primary text-primary-foreground font-bold'
|
||||
: 'text-muted-foreground'
|
||||
}`}
|
||||
>
|
||||
{format(day, 'd')}
|
||||
</span>
|
||||
<div className="space-y-1">
|
||||
{dayEpisodes.slice(0, 4).map((ep) => (
|
||||
<EpisodeCalendarItem key={ep.id} episode={ep} />
|
||||
))}
|
||||
{dayEpisodes.length > 4 && (
|
||||
<span className="text-[10px] text-muted-foreground pl-1">
|
||||
+{dayEpisodes.length - 4} more
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</TooltipProvider>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function EpisodeCalendarItem({ episode }: { episode: Episode }) {
|
||||
type EpisodeWithEntry = Episode & {
|
||||
entry?: {
|
||||
id: number;
|
||||
title?: string;
|
||||
poster_path?: string | null;
|
||||
medias?: unknown[];
|
||||
isInLibrary?: boolean;
|
||||
};
|
||||
};
|
||||
const ep = episode as EpisodeWithEntry;
|
||||
const entry = ep.entry;
|
||||
const entryId = entry?.id;
|
||||
const entryTitle = entry?.title ?? '';
|
||||
const seasonId = episode.season_id;
|
||||
|
||||
const posterSrc = episode.still_path
|
||||
? getTmdbPosterUrl(episode.still_path, 'w92')
|
||||
: entry
|
||||
? getPosterUrl({ ...(entry as Parameters<typeof getPosterUrl>[0]), isInLibrary: false })
|
||||
: undefined;
|
||||
|
||||
const seasonLabel = `S${String(seasonId).padStart(2, '0')}`;
|
||||
const episodeLabel = `E${String(episode.episode_number).padStart(2, '0')}`;
|
||||
|
||||
const content = (
|
||||
<div className="flex items-center gap-1.5 rounded bg-accent/60 hover:bg-accent px-1 py-1 transition-colors cursor-pointer">
|
||||
{posterSrc && (
|
||||
<img
|
||||
src={posterSrc}
|
||||
alt=""
|
||||
className="h-10 w-7 rounded object-cover shrink-0"
|
||||
/>
|
||||
)}
|
||||
<div className="min-w-0">
|
||||
<p className="text-[10px] font-medium truncate leading-tight">
|
||||
{entryTitle}
|
||||
</p>
|
||||
<p className="text-[9px] text-muted-foreground tabular-nums">
|
||||
{seasonLabel} {episodeLabel}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
{entryId ? (
|
||||
<Link
|
||||
to={`/entry/${entryId}/season/${seasonId}/episode/${episode.id}`}
|
||||
className="block"
|
||||
>
|
||||
{content}
|
||||
</Link>
|
||||
) : (
|
||||
<div>{content}</div>
|
||||
)}
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="right" className="max-w-50">
|
||||
<p className="text-xs font-semibold">{entryTitle}</p>
|
||||
{episode.name && (
|
||||
<p className="text-xs">{episode.name}</p>
|
||||
)}
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{seasonLabel} {episodeLabel}
|
||||
</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
import { useState } from 'react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { useParams, Link } from 'react-router-dom';
|
||||
import { useEntry, useEntrySeasons, useRefreshEntry } from '@/hooks/useEntries';
|
||||
import { useEntrySeenByEntry, useDeleteEntrySeen } from '@/hooks/useEntrySeen';
|
||||
import { useCollections } from '@/hooks/useCollections';
|
||||
import { useLibraryStore } from '@/stores/useLibraryStore';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Separator } from '@/components/ui/separator';
|
||||
import { ScrollArea, ScrollBar } from '@/components/ui/scroll-area';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
@@ -33,20 +35,21 @@ import {
|
||||
import { CastList } from '@/components/entries/CastList';
|
||||
import { SeasonsContainer } from '@/components/entries/SeasonsContainer';
|
||||
import { EpisodeWatchHistory } from '@/components/entries/EpisodeWatchHistory';
|
||||
import { CollectionsGrid } from '@/components/collections/CollectionsGrid';
|
||||
import { EntrySettingsDialog } from '@/components/dialogs/EntrySettingsDialog';
|
||||
import { EntrySeenDialog } from '@/components/dialogs/EntrySeenDialog';
|
||||
import { EntryMediaDialog } from '@/components/dialogs/EntryMediaDialog';
|
||||
import { AddEntryToCollectionDialog } from '@/components/dialogs/AddEntryToCollectionDialog';
|
||||
import { RatingDialog } from '@/components/dialogs/RatingDialog';
|
||||
import {
|
||||
getPosterUrl,
|
||||
getBackdropUrl,
|
||||
getCollectionBackdropUrl,
|
||||
getYear,
|
||||
formatRuntime,
|
||||
formatDate,
|
||||
} from '@/lib/media-utils';
|
||||
import { useUpdateEntry } from '@/hooks/useEntries';
|
||||
import type { Entry } from '@/types';
|
||||
import type { Collection, Entry } from '@/types';
|
||||
|
||||
export function EntryDetailsPage() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
@@ -64,11 +67,11 @@ export function EntryDetailsPage() {
|
||||
? { ...libraryEntry, ...entry, isInLibrary: true }
|
||||
: entry || libraryEntry;
|
||||
|
||||
// Dialog states
|
||||
const [showSettings, setShowSettings] = useState(false);
|
||||
const [showSeenDialog, setShowSeenDialog] = useState(false);
|
||||
const [showMediaDialog, setShowMediaDialog] = useState(false);
|
||||
const [showCollectionDialog, setShowCollectionDialog] = useState(false);
|
||||
const [showRatingDialog, setShowRatingDialog] = useState(false);
|
||||
|
||||
if (isLoading || !displayEntry) {
|
||||
return <EntryDetailsSkeleton />;
|
||||
@@ -86,37 +89,120 @@ export function EntryDetailsPage() {
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-8">
|
||||
{/* Hero Section */}
|
||||
<div className="relative -mx-6 -mt-6 overflow-hidden">
|
||||
{backdrop && (
|
||||
<div>
|
||||
{/* Backdrop banner */}
|
||||
<div className="relative -mx-6 -mt-6 h-52 overflow-hidden">
|
||||
{backdrop ? (
|
||||
<img
|
||||
src={backdrop}
|
||||
alt=""
|
||||
className="h-72 w-full object-cover opacity-30 blur-sm"
|
||||
className="h-full w-full object-cover opacity-25 blur-sm scale-105"
|
||||
/>
|
||||
) : (
|
||||
<div className="h-full w-full bg-linear-to-br from-primary/15 to-primary/5" />
|
||||
)}
|
||||
<div className="absolute inset-0 bg-gradient-to-t from-background to-transparent" />
|
||||
<div className="absolute inset-0 bg-linear-to-t from-background via-background/60 to-transparent" />
|
||||
</div>
|
||||
|
||||
<div className="relative mx-auto flex max-w-5xl gap-6 px-6 pb-6 pt-4">
|
||||
{/* Poster */}
|
||||
<div className="shrink-0">
|
||||
{/* Main content */}
|
||||
<div className="mx-auto max-w-4xl">
|
||||
{/* Two-column header: sticky poster | info */}
|
||||
<div className="flex gap-8 -mt-24 relative items-start">
|
||||
{/* LEFT: Sticky poster + actions */}
|
||||
<div className="sticky top-20 w-44 shrink-0 space-y-3 self-start">
|
||||
<img
|
||||
src={poster}
|
||||
alt={e.title}
|
||||
className="h-72 w-48 rounded-lg object-cover shadow-lg"
|
||||
className="w-full aspect-2/3 rounded-xl object-cover shadow-2xl ring-1 ring-border/50"
|
||||
/>
|
||||
<div className="flex flex-col gap-2">
|
||||
<Button
|
||||
variant={e.favorit ? 'default' : 'outline'}
|
||||
size="sm"
|
||||
className="w-full justify-start"
|
||||
onClick={toggleFavorite}
|
||||
>
|
||||
<Heart className={`mr-2 h-4 w-4 ${e.favorit ? 'fill-current' : ''}`} />
|
||||
{e.favorit ? 'Favorited' : 'Favorite'}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="w-full justify-start"
|
||||
onClick={() => setShowSeenDialog(true)}
|
||||
>
|
||||
<Eye className="mr-2 h-4 w-4" />
|
||||
Mark Watched
|
||||
</Button>
|
||||
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="ghost" size="sm" className="w-full justify-start">
|
||||
<MoreHorizontal className="mr-2 h-4 w-4" />
|
||||
More actions
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="start" side="right" className="w-56">
|
||||
<DropdownMenuItem onClick={() => setShowRatingDialog(true)}>
|
||||
<Star className="mr-2 h-4 w-4" />
|
||||
Rate this
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
onClick={() =>
|
||||
updateEntry.mutate({ id: e.id, data: { hidden: !e.hidden } })
|
||||
}
|
||||
>
|
||||
<EyeOff className="mr-2 h-4 w-4" />
|
||||
{e.hidden ? 'Unhide' : 'Hide'}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => refreshEntry.mutate(e.id)}>
|
||||
<RefreshCw className="mr-2 h-4 w-4" />
|
||||
Refresh details
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => setShowCollectionDialog(true)}>
|
||||
<FolderPlus className="mr-2 h-4 w-4" />
|
||||
Add to collection
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => setShowMediaDialog(true)}>
|
||||
<ImageIcon className="mr-2 h-4 w-4" />
|
||||
Manage media
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => setShowSettings(true)}>
|
||||
<Settings className="mr-2 h-4 w-4" />
|
||||
Settings
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Info */}
|
||||
<div className="flex flex-1 flex-col justify-end space-y-3">
|
||||
<div className="flex items-center gap-3">
|
||||
<h1 className="text-3xl font-bold">{e.title}</h1>
|
||||
{e.status && (
|
||||
<Badge variant="secondary">{e.status}</Badge>
|
||||
{/* RIGHT: Entry info */}
|
||||
<div className="flex-1 min-w-0 space-y-4">
|
||||
{/* Title + status + director */}
|
||||
<div className="space-y-1">
|
||||
<div className="flex flex-wrap items-start gap-2">
|
||||
<h1 className="text-3xl font-bold leading-tight">{e.title}</h1>
|
||||
{e.status && (
|
||||
<Badge variant="secondary" className="mt-1 shrink-0">
|
||||
{e.status}
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
{director && (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
by{' '}
|
||||
<Link
|
||||
to={`/people/${director.people_id}`}
|
||||
className="font-medium text-foreground hover:underline"
|
||||
>
|
||||
{director.people?.name}
|
||||
</Link>
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Meta */}
|
||||
<div className="flex flex-wrap items-center gap-2 text-sm text-muted-foreground">
|
||||
{e.release_date && (
|
||||
<TooltipProvider>
|
||||
@@ -138,12 +224,6 @@ export function EntryDetailsPage() {
|
||||
<span>{formatRuntime(e.runtime)}</span>
|
||||
</>
|
||||
)}
|
||||
{director && (
|
||||
<>
|
||||
<span>•</span>
|
||||
<span>Dir. {director.people?.name}</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Genres */}
|
||||
@@ -158,145 +238,83 @@ export function EntryDetailsPage() {
|
||||
)}
|
||||
|
||||
{/* Ratings */}
|
||||
<div className="flex items-center gap-4">
|
||||
{e.entryRatings?.user_rating != null &&
|
||||
e.entryRatings.user_rating > 0 && (
|
||||
<div className="flex items-center gap-1">
|
||||
<Star className="h-4 w-4 fill-yellow-400 text-yellow-400" />
|
||||
<span className="text-sm font-medium">
|
||||
{e.entryRatings.user_rating}/10
|
||||
</span>
|
||||
<span className="text-xs text-muted-foreground">You</span>
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
{e.entryRatings?.imdb_rating != null &&
|
||||
e.entryRatings.imdb_rating > 0 && (
|
||||
<span className="inline-flex items-center gap-1 rounded-full bg-yellow-500/10 border border-yellow-500/20 px-3 py-1 text-sm text-yellow-600 dark:text-yellow-400 font-medium">
|
||||
<span className="font-bold">IMDb:</span>
|
||||
{e.entryRatings.imdb_rating}/10
|
||||
</span>
|
||||
)}
|
||||
{e.entryRatings?.tmdb_rating != null &&
|
||||
e.entryRatings.tmdb_rating > 0 && (
|
||||
<div className="flex items-center gap-1">
|
||||
<span className="text-sm font-medium">
|
||||
{e.entryRatings.tmdb_rating.toFixed(1)}
|
||||
</span>
|
||||
<span className="text-xs text-muted-foreground">TMDB</span>
|
||||
</div>
|
||||
)}
|
||||
{e.entryRatings?.imdb_rating != null &&
|
||||
e.entryRatings.imdb_rating > 0 && (
|
||||
<div className="flex items-center gap-1">
|
||||
<span className="text-sm font-medium">
|
||||
{e.entryRatings.imdb_rating}
|
||||
</span>
|
||||
<span className="text-xs text-muted-foreground">IMDb</span>
|
||||
</div>
|
||||
<span className="inline-flex items-center gap-1 rounded-full bg-blue-500/10 border border-blue-500/20 px-3 py-1 text-sm text-blue-600 dark:text-blue-400 font-medium">
|
||||
<span className="font-bold">TMDB:</span>
|
||||
{e.entryRatings.tmdb_rating.toFixed(1)}/10
|
||||
</span>
|
||||
)}
|
||||
{e.entryRatings?.user_rating != null &&
|
||||
e.entryRatings.user_rating > 0 ? (
|
||||
<button
|
||||
className="inline-flex items-center gap-1 rounded-full bg-accent border border-border px-3 py-1 text-sm font-medium hover:bg-accent/80 transition-colors"
|
||||
onClick={() => setShowRatingDialog(true)}
|
||||
title="Click to change rating"
|
||||
>
|
||||
<Star className="h-3.5 w-3.5 fill-yellow-400 text-yellow-400" />
|
||||
<span className="font-bold">You:</span>
|
||||
{e.entryRatings.user_rating}/10
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
className="inline-flex items-center gap-1.5 rounded-full border border-dashed border-border px-3 py-1 text-sm text-muted-foreground hover:border-border hover:text-foreground transition-colors"
|
||||
onClick={() => setShowRatingDialog(true)}
|
||||
>
|
||||
<Star className="h-3.5 w-3.5" />
|
||||
Rate
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Actions */}
|
||||
<div className="flex items-center gap-2 pt-2">
|
||||
<Button
|
||||
variant={e.favorit ? 'default' : 'outline'}
|
||||
size="sm"
|
||||
onClick={toggleFavorite}
|
||||
>
|
||||
<Heart
|
||||
className={`mr-1 h-4 w-4 ${
|
||||
e.favorit ? 'fill-current' : ''
|
||||
}`}
|
||||
/>
|
||||
{e.favorit ? 'Favorited' : 'Favorite'}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => setShowSeenDialog(true)}
|
||||
>
|
||||
<Eye className="mr-1 h-4 w-4" />
|
||||
Mark Watched
|
||||
</Button>
|
||||
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="outline" size="icon" className="h-8 w-8">
|
||||
<MoreHorizontal className="h-4 w-4" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem
|
||||
onClick={() =>
|
||||
updateEntry.mutate({
|
||||
id: e.id,
|
||||
data: { hidden: !e.hidden },
|
||||
})
|
||||
}
|
||||
>
|
||||
<EyeOff className="mr-2 h-4 w-4" />
|
||||
{e.hidden ? 'Unhide' : 'Hide'}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
onClick={() => refreshEntry.mutate(e.id)}
|
||||
>
|
||||
<RefreshCw className="mr-2 h-4 w-4" />
|
||||
Refresh Details
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
onClick={() => setShowCollectionDialog(true)}
|
||||
>
|
||||
<FolderPlus className="mr-2 h-4 w-4" />
|
||||
Add to Collection
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
onClick={() => setShowMediaDialog(true)}
|
||||
>
|
||||
<ImageIcon className="mr-2 h-4 w-4" />
|
||||
Media
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
onClick={() => setShowSettings(true)}
|
||||
>
|
||||
<Settings className="mr-2 h-4 w-4" />
|
||||
Settings
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
{/* Storyline */}
|
||||
{e.storyline && (
|
||||
<p className="text-sm text-muted-foreground leading-relaxed max-w-prose">
|
||||
{e.storyline}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Storyline */}
|
||||
{e.storyline && (
|
||||
<div className="space-y-2">
|
||||
<h3 className="text-lg font-semibold">Overview</h3>
|
||||
<p className="text-sm text-muted-foreground leading-relaxed">
|
||||
{e.storyline}
|
||||
</p>
|
||||
{/* Sections */}
|
||||
<div className="mt-10 space-y-8">
|
||||
{e.credits && e.credits.length > 0 && (
|
||||
<>
|
||||
<Separator />
|
||||
<CastList credits={e.credits} />
|
||||
</>
|
||||
)}
|
||||
|
||||
<EntryCollectionsSection entryId={e.id} />
|
||||
|
||||
{e.is_tvseries && seasons && seasons.length > 0 && (
|
||||
<>
|
||||
<Separator />
|
||||
<SeasonsContainer seasons={seasons} entryId={e.id} />
|
||||
</>
|
||||
)}
|
||||
|
||||
{watchHistory.length > 0 && (
|
||||
<>
|
||||
<Separator />
|
||||
<EpisodeWatchHistory
|
||||
watchHistory={watchHistory}
|
||||
onDelete={(seenId) =>
|
||||
deleteEntrySeen.mutate({ id: seenId, entryId: e.id })
|
||||
}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Separator />
|
||||
|
||||
{/* Cast */}
|
||||
{e.credits && e.credits.length > 0 && <CastList credits={e.credits} />}
|
||||
|
||||
{/* Seasons (TV only) */}
|
||||
{e.is_tvseries && seasons && seasons.length > 0 && (
|
||||
<>
|
||||
<Separator />
|
||||
<SeasonsContainer seasons={seasons} entryId={e.id} />
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* Watch History */}
|
||||
{watchHistory.length > 0 && (
|
||||
<>
|
||||
<Separator />
|
||||
<EpisodeWatchHistory
|
||||
watchHistory={watchHistory}
|
||||
onDelete={(seenId) =>
|
||||
deleteEntrySeen.mutate({ id: seenId, entryId: e.id })
|
||||
}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Dialogs */}
|
||||
{showSettings && (
|
||||
@@ -330,22 +348,81 @@ export function EntryDetailsPage() {
|
||||
entryId={e.id}
|
||||
/>
|
||||
)}
|
||||
{showRatingDialog && (
|
||||
<RatingDialog
|
||||
open={showRatingDialog}
|
||||
onOpenChange={setShowRatingDialog}
|
||||
entry={e}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/* ---------- Collections section ---------- */
|
||||
function EntryCollectionsSection({ entryId }: { entryId: number }) {
|
||||
const { data: allCollections = [], isLoading } = useCollections();
|
||||
|
||||
const collections = allCollections.filter((col: Collection) =>
|
||||
col.entries?.some((e: Entry) => e.id === entryId)
|
||||
);
|
||||
|
||||
if (isLoading || collections.length === 0) return null;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Separator />
|
||||
<div className="space-y-3">
|
||||
<h3 className="text-lg font-semibold">In Collections</h3>
|
||||
<ScrollArea className="w-full">
|
||||
<div className="flex gap-4 pb-4">
|
||||
{collections.map((col: Collection) => (
|
||||
<Link
|
||||
key={col.id}
|
||||
to={`/collections/${col.id}`}
|
||||
className="group shrink-0 w-56 overflow-hidden rounded-lg relative block"
|
||||
>
|
||||
<div className="aspect-video w-full overflow-hidden bg-muted rounded-lg">
|
||||
<img
|
||||
src={getCollectionBackdropUrl(col)}
|
||||
alt={col.name}
|
||||
className="h-full w-full object-cover transition-transform group-hover:scale-105"
|
||||
/>
|
||||
</div>
|
||||
<div className="absolute inset-0 bg-linear-to-t from-black/70 via-black/20 to-transparent rounded-lg" />
|
||||
<div className="absolute bottom-0 left-0 right-0 p-3">
|
||||
<p className="text-sm font-medium text-white line-clamp-2 leading-tight">
|
||||
{col.name}
|
||||
</p>
|
||||
{col.entries && (
|
||||
<p className="text-xs text-white/70 mt-0.5">
|
||||
{col.entries.length} {col.entries.length === 1 ? 'title' : 'titles'}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
<ScrollBar orientation="horizontal" />
|
||||
</ScrollArea>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function EntryDetailsSkeleton() {
|
||||
return (
|
||||
<div className="space-y-8">
|
||||
<div className="flex gap-6">
|
||||
<Skeleton className="h-72 w-48 shrink-0 rounded-lg" />
|
||||
<div className="flex-1 space-y-4">
|
||||
<div>
|
||||
<div className="h-52 -mx-6 -mt-6 bg-muted animate-pulse" />
|
||||
<div className="max-w-4xl mx-auto flex gap-8 -mt-24">
|
||||
<Skeleton className="h-64 w-44 shrink-0 rounded-xl" />
|
||||
<div className="flex-1 space-y-4 pt-24">
|
||||
<Skeleton className="h-8 w-64" />
|
||||
<Skeleton className="h-4 w-40" />
|
||||
<Skeleton className="h-4 w-32" />
|
||||
<Skeleton className="h-4 w-80" />
|
||||
<div className="flex gap-2">
|
||||
<Skeleton className="h-8 w-24" />
|
||||
<Skeleton className="h-8 w-32" />
|
||||
<Skeleton className="h-6 w-16" />
|
||||
<Skeleton className="h-6 w-12" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -67,7 +67,7 @@ export function PeoplePage() {
|
||||
ref={index === people.length - 1 ? lastRef : undefined}
|
||||
>
|
||||
<Link
|
||||
to={`/people/${person.id}`}
|
||||
to={`/people/tmdb/${person.id}`}
|
||||
className="group flex flex-col items-center gap-2 text-center"
|
||||
>
|
||||
<Avatar className="h-24 w-24 transition-transform group-hover:scale-105">
|
||||
|
||||
@@ -1,18 +1,24 @@
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { usePerson } from '@/hooks/usePeople';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { peopleApi } from '@/api/people';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { usePerson, usePersonTmdbFilmography } from '@/hooks/usePeople';
|
||||
import { useLibrary } from '@/hooks/useEntries';
|
||||
import { useLibraryStore } from '@/stores/useLibraryStore';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
|
||||
import { Separator } from '@/components/ui/separator';
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { EntryCard } from '@/components/entries/EntryCard';
|
||||
import { getProfileUrl, formatDate } from '@/lib/media-utils';
|
||||
import { getTmdbImageUrl } from '@/lib/api';
|
||||
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 { data: tmdbFilmography, isLoading: tmdbLoading } = usePersonTmdbFilmography(personId);
|
||||
useLibrary();
|
||||
const libraryMap = useLibraryStore((s) => s.entries);
|
||||
const libraryLoaded = useLibraryStore((s) => s.isLoaded);
|
||||
|
||||
if (isLoading || !person) {
|
||||
return (
|
||||
@@ -31,47 +37,21 @@ export function PersonDetailsPage() {
|
||||
|
||||
return (
|
||||
<div className="space-y-8">
|
||||
{/* Profile header */}
|
||||
<div className="flex gap-8">
|
||||
<Avatar className="h-48 w-48 shrink-0">
|
||||
<AvatarImage
|
||||
src={getProfileUrl(person.profile_path)}
|
||||
alt={person.name}
|
||||
/>
|
||||
<AvatarImage src={getProfileUrl(person.profile_path)} alt={person.name} />
|
||||
<AvatarFallback className="text-3xl">
|
||||
{person.name
|
||||
.split(' ')
|
||||
.map((n: string) => n[0])
|
||||
.join('')}
|
||||
{person.name.split(' ').map((n: string) => n[0]).join('')}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
|
||||
<div className="space-y-3">
|
||||
<h1 className="text-3xl font-bold">{person.name}</h1>
|
||||
<div className="flex flex-wrap items-center gap-3 text-sm text-muted-foreground">
|
||||
{person.known_for_department && (
|
||||
<span>{person.known_for_department}</span>
|
||||
)}
|
||||
{person.birthday && (
|
||||
<>
|
||||
<span>•</span>
|
||||
<span>Born: {formatDate(person.birthday)}</span>
|
||||
</>
|
||||
)}
|
||||
{person.deathday && (
|
||||
<>
|
||||
<span>•</span>
|
||||
<span>Died: {formatDate(person.deathday)}</span>
|
||||
</>
|
||||
)}
|
||||
{person.place_of_birth && (
|
||||
<>
|
||||
<span>•</span>
|
||||
<span>{person.place_of_birth}</span>
|
||||
</>
|
||||
)}
|
||||
{person.known_for_department && <span>{person.known_for_department}</span>}
|
||||
{person.birthday && (<><span>•</span><span>Born: {formatDate(person.birthday)}</span></>)}
|
||||
{person.deathday && (<><span>•</span><span>Died: {formatDate(person.deathday)}</span></>)}
|
||||
{person.place_of_birth && (<><span>•</span><span>{person.place_of_birth}</span></>)}
|
||||
</div>
|
||||
|
||||
{person.biography && (
|
||||
<p className="text-sm text-muted-foreground leading-relaxed max-w-2xl line-clamp-6">
|
||||
{person.biography}
|
||||
@@ -82,13 +62,118 @@ export function PersonDetailsPage() {
|
||||
|
||||
<Separator />
|
||||
|
||||
{/* Filmography placeholder */}
|
||||
<FilmographySection
|
||||
libraryMap={libraryMap}
|
||||
libraryLoaded={libraryLoaded}
|
||||
tmdbFilmography={tmdbFilmography}
|
||||
tmdbLoading={tmdbLoading}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
interface FilmographySectionProps {
|
||||
libraryMap: Map<number, import('@/types').Entry>;
|
||||
libraryLoaded: boolean;
|
||||
tmdbFilmography?: { cast: TmdbFilmographyItem[]; crew: TmdbFilmographyItem[] };
|
||||
tmdbLoading: boolean;
|
||||
}
|
||||
|
||||
function FilmographySection({ libraryMap, libraryLoaded, tmdbFilmography, tmdbLoading }: FilmographySectionProps) {
|
||||
if (tmdbLoading || !libraryLoaded) {
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<h2 className="text-xl font-semibold">Filmography</h2>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Filmography details will be loaded from credits associated with this person.
|
||||
</p>
|
||||
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5">
|
||||
{Array.from({ length: 10 }).map((_, i) => (
|
||||
<Skeleton key={i} className="aspect-2/3 rounded-lg" />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const allTmdbCredits = [
|
||||
...(tmdbFilmography?.cast ?? []),
|
||||
...(tmdbFilmography?.crew?.filter((c) => c.job === 'Director' || c.department === 'Directing') ?? []),
|
||||
];
|
||||
const seenTmdbIds = new Set<number>();
|
||||
const dedupedCredits = allTmdbCredits.filter((c) => {
|
||||
if (seenTmdbIds.has(c.id)) return false;
|
||||
seenTmdbIds.add(c.id);
|
||||
return true;
|
||||
});
|
||||
|
||||
const tmdbIdToLibraryEntry = new Map<number, import('@/types').Entry>();
|
||||
for (const entry of libraryMap.values()) {
|
||||
if (entry.entryIds?.tmdb_id != null) {
|
||||
tmdbIdToLibraryEntry.set(Number(entry.entryIds.tmdb_id), entry);
|
||||
}
|
||||
}
|
||||
|
||||
const libraryCredits = dedupedCredits.filter((c) => tmdbIdToLibraryEntry.has(c.id));
|
||||
const otherCredits = dedupedCredits.filter((c) => !tmdbIdToLibraryEntry.has(c.id));
|
||||
|
||||
if (dedupedCredits.length === 0) {
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<h2 className="text-xl font-semibold">Filmography</h2>
|
||||
<p className="text-sm text-muted-foreground">No filmography found.</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-8">
|
||||
<h2 className="text-xl font-semibold">Filmography</h2>
|
||||
|
||||
{libraryCredits.length > 0 && (
|
||||
<div className="space-y-3">
|
||||
<h3 className="text-sm font-medium text-muted-foreground uppercase tracking-wide">In Your Library</h3>
|
||||
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5">
|
||||
{libraryCredits.map((credit) => {
|
||||
const entry = tmdbIdToLibraryEntry.get(credit.id)!;
|
||||
return (
|
||||
<div key={credit.id} className="space-y-1">
|
||||
<EntryCard entry={entry} />
|
||||
{credit.character && (
|
||||
<p className="text-xs text-muted-foreground text-center line-clamp-1 px-1">{credit.character}</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{otherCredits.length > 0 && (
|
||||
<div className="space-y-3">
|
||||
<h3 className="text-sm font-medium text-muted-foreground uppercase tracking-wide">Not in Library</h3>
|
||||
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5">
|
||||
{otherCredits.map((credit) => {
|
||||
const title = credit.title ?? credit.name ?? 'Unknown';
|
||||
const posterSrc = credit.poster_path
|
||||
? getTmdbImageUrl(credit.poster_path, 'w342')
|
||||
: '/images/default-poster.png';
|
||||
return (
|
||||
<div key={credit.id} className="space-y-1">
|
||||
<div className="relative aspect-2/3 overflow-hidden rounded-lg bg-muted">
|
||||
<img src={posterSrc} alt={title} className="h-full w-full object-cover" />
|
||||
<div className="absolute inset-0 bg-linear-to-t from-black/60 to-transparent" />
|
||||
<p className="absolute bottom-0 left-0 right-0 p-2 text-xs font-medium text-white line-clamp-2">{title}</p>
|
||||
<Badge variant="secondary" className="absolute top-1.5 right-1.5 text-[9px] px-1 py-0">
|
||||
{credit.media_type === 'tv' ? 'TV' : 'Movie'}
|
||||
</Badge>
|
||||
</div>
|
||||
{credit.character && (
|
||||
<p className="text-xs text-muted-foreground text-center line-clamp-1 px-1">{credit.character}</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useParams, useNavigate } from 'react-router-dom';
|
||||
import { useFetchPersonByTmdbId } from '@/hooks/usePeople';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
|
||||
export function PersonTmdbRedirectPage() {
|
||||
const { tmdbId } = useParams<{ tmdbId: string }>();
|
||||
const navigate = useNavigate();
|
||||
const fetchPerson = useFetchPersonByTmdbId();
|
||||
|
||||
useEffect(() => {
|
||||
if (!tmdbId) return;
|
||||
fetchPerson.mutate(parseInt(tmdbId, 10), {
|
||||
onSuccess: (person) => {
|
||||
navigate(`/people/${person.id}`, { replace: true });
|
||||
},
|
||||
});
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [tmdbId]);
|
||||
|
||||
if (fetchPerson.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">
|
||||
Could not load person data from TMDB.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div className="flex gap-6">
|
||||
<Skeleton className="h-48 w-48 rounded-full" />
|
||||
<div className="flex-1 space-y-3">
|
||||
<Skeleton className="h-8 w-48" />
|
||||
<Skeleton className="h-4 w-32" />
|
||||
<Skeleton className="h-20 w-full" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user