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:
1 parent
25b645a16f
commit
02cdcf733d
18 files changed
+949
-204
No files matched your search
@@ -9,8 +9,9 @@ import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { Progress } from '@/components/ui/progress';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Eye, CheckCircle2, ListChecks } from 'lucide-react';
|
||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
|
||||
import { getTmdbPosterUrl, getYear, formatDate } from '@/lib/media-utils';
|
||||
import type { Episode } from '@/types';
|
||||
import type { Episode, EpisodeSeen } from '@/types';
|
||||
|
||||
export function SeasonPage() {
|
||||
const { entryId, seasonId } = useParams<{
|
||||
@@ -39,7 +40,7 @@ export function SeasonPage() {
|
||||
}
|
||||
|
||||
const watchedCount = episodes.filter(
|
||||
(ep) =>
|
||||
(ep: Episode) =>
|
||||
ep.date_first_seen ||
|
||||
(ep.episodeSeens && ep.episodeSeens.length > 0)
|
||||
).length;
|
||||
@@ -61,20 +62,20 @@ export function SeasonPage() {
|
||||
</div>
|
||||
|
||||
{/* Header */}
|
||||
<div className="flex gap-6">
|
||||
<div className="flex flex-col gap-4 sm:flex-row sm:gap-6">
|
||||
<img
|
||||
src={getTmdbPosterUrl(season.poster_path, 'w185')}
|
||||
alt={season.name}
|
||||
className="h-56 w-36 shrink-0 rounded-lg object-cover shadow-lg"
|
||||
className="h-40 w-28 shrink-0 rounded-lg object-cover shadow-lg self-center sm:self-start sm:h-56 sm:w-36"
|
||||
/>
|
||||
<div className="flex-1 flex flex-col justify-center space-y-3">
|
||||
<div className="flex items-start justify-between gap-4">
|
||||
<h1 className="text-2xl font-bold">{season.name}</h1>
|
||||
<div className="flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between sm:gap-4">
|
||||
<h1 className="text-xl font-bold sm:text-2xl">{season.name}</h1>
|
||||
{/* Mark Season as Watched — top right */}
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="shrink-0"
|
||||
className="shrink-0 w-full sm:w-auto"
|
||||
onClick={() => setShowMarkAllDialog(true)}
|
||||
>
|
||||
<ListChecks className="mr-1.5 h-4 w-4" />
|
||||
@@ -113,19 +114,20 @@ export function SeasonPage() {
|
||||
<div className="space-y-3">
|
||||
<h3 className="text-lg font-semibold">Episodes</h3>
|
||||
<div className="space-y-2">
|
||||
{episodes.map((episode) => {
|
||||
{episodes.map((episode: Episode) => {
|
||||
const isWatched =
|
||||
!!episode.date_first_seen ||
|
||||
(episode.episodeSeens && episode.episodeSeens.length > 0);
|
||||
const seenDates = (episode.episodeSeens ?? []).map((s: EpisodeSeen) => s.date_seen);
|
||||
|
||||
return (
|
||||
<Link
|
||||
key={episode.id}
|
||||
to={`/entry/${entryId}/season/${seasonId}/episode/${episode.id}`}
|
||||
className="flex gap-4 rounded-lg border border-border p-3 transition-colors hover:bg-accent/50"
|
||||
className="flex gap-3 rounded-lg border border-border p-2 transition-colors hover:bg-accent/50 sm:gap-4 sm:p-3"
|
||||
>
|
||||
{/* Thumbnail */}
|
||||
<div className="h-16 w-28 shrink-0 overflow-hidden rounded bg-muted">
|
||||
<div className="h-14 w-24 shrink-0 overflow-hidden rounded bg-muted sm:h-16 sm:w-28">
|
||||
{episode.still_path ? (
|
||||
<img
|
||||
src={getTmdbPosterUrl(episode.still_path, 'w300')}
|
||||
@@ -153,11 +155,40 @@ export function SeasonPage() {
|
||||
<CheckCircle2 className="h-4 w-4 shrink-0 text-green-500" />
|
||||
)}
|
||||
</div>
|
||||
{episode.air_date && (
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{formatDate(episode.air_date)}
|
||||
</p>
|
||||
)}
|
||||
<div className="flex items-center gap-2 flex-wrap">
|
||||
{episode.air_date && (
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{formatDate(episode.air_date)}
|
||||
</p>
|
||||
)}
|
||||
{seenDates.length > 0 && (
|
||||
<>
|
||||
<span className="text-xs text-muted-foreground">•</span>
|
||||
{seenDates.length === 1 ? (
|
||||
<span className="text-xs text-green-600 dark:text-green-400">
|
||||
Seen {formatDate(seenDates[0])}
|
||||
</span>
|
||||
) : (
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger>
|
||||
<span className="text-xs text-green-600 dark:text-green-400 cursor-default underline decoration-dotted">
|
||||
Seen {seenDates.length} times
|
||||
</span>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<div className="space-y-0.5 text-xs">
|
||||
{seenDates.map((d: string, i: number) => (
|
||||
<p key={i}>{formatDate(d)}</p>
|
||||
))}
|
||||
</div>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
{episode.overview && (
|
||||
<p className="mt-1 text-xs text-muted-foreground line-clamp-2">
|
||||
{episode.overview}
|
||||
@@ -165,7 +196,7 @@ export function SeasonPage() {
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Watch button */}
|
||||
{/* Watch button — always clickable to add another seen record */}
|
||||
<Button
|
||||
size="icon"
|
||||
variant={isWatched ? 'secondary' : 'outline'}
|
||||
@@ -173,11 +204,8 @@ export function SeasonPage() {
|
||||
onClick={(ev) => {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
if (!isWatched) {
|
||||
setDialogEpisode(episode);
|
||||
}
|
||||
setDialogEpisode(episode);
|
||||
}}
|
||||
disabled={isWatched}
|
||||
>
|
||||
<Eye className="h-4 w-4" />
|
||||
</Button>
|
||||
|
||||
Reference in new issue
Block a user