Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c6023cc52 | ||
|
|
67c828838d | ||
|
|
cd2c135c65 | ||
|
|
f88dfdae44 |
No files matched your search
@@ -12,6 +12,7 @@ environment.ts
|
|||||||
circular-dependencies.png
|
circular-dependencies.png
|
||||||
.agents/skills
|
.agents/skills
|
||||||
auto_puller.py
|
auto_puller.py
|
||||||
|
/brain
|
||||||
|
|
||||||
# Compiled output
|
# Compiled output
|
||||||
.angular
|
.angular
|
||||||
|
|||||||
@@ -11,33 +11,6 @@ You can get project context from the following files:
|
|||||||
|
|
||||||
## Mandatory Task Completion Rule
|
## Mandatory Task Completion Rule
|
||||||
|
|
||||||
#### Update the `changes.md` file after completing any task requested by the user.
|
|
||||||
|
|
||||||
After completing ANY task requested by the user, you MUST update the file `changes.md`.
|
|
||||||
Append a new section at the end of `changes.md` using this exact format:
|
|
||||||
|
|
||||||
```md
|
|
||||||
### Milestone XXX
|
|
||||||
|
|
||||||
#### Backend Changes
|
|
||||||
|
|
||||||
- <change 1>
|
|
||||||
- <change 2>
|
|
||||||
- <change 3>
|
|
||||||
|
|
||||||
#### Frontend Changes
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Rules
|
|
||||||
|
|
||||||
- Always ask the user if this is a new milestone or if you should continue appending to the current milestone.
|
|
||||||
- Replace `XXX` with the task number provided by the user (example: `025`).
|
|
||||||
- The bullet list must include all important modifications made.
|
|
||||||
- Do NOT overwrite previous entries: always APPEND.
|
|
||||||
- If `changes.md` does not exist, create it.
|
|
||||||
- If no task number is provided, use the next available number based on the last entry in the file.
|
|
||||||
- Always ensure formatting matches exactly (heading + code block + bullets).
|
|
||||||
|
|
||||||
### Documentation (Skip the legacy docs, we're using obsidian docs-vault now)
|
### Documentation (Skip the legacy docs, we're using obsidian docs-vault now)
|
||||||
|
|
||||||
Update the `/backend/docs` and `/react_frontend/docs` folders with any relevant documentation changes related to the task you completed. This includes API documentation, architectural diagrams, or any other relevant docs.
|
Update the `/backend/docs` and `/react_frontend/docs` folders with any relevant documentation changes related to the task you completed. This includes API documentation, architectural diagrams, or any other relevant docs.
|
||||||
|
|||||||
Generated
+915
-2575
File diff suppressed because it is too large.
Load diff
@@ -49,9 +49,8 @@
|
|||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"electron": "^34.0.1",
|
"electron": "^45.1.0",
|
||||||
"electron-builder": "^25.1.8"
|
"electron-builder": "^26.18.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Generated
+748
-445
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,32 @@
|
|||||||
|
allowBuilds:
|
||||||
|
msw: false
|
||||||
|
overrides:
|
||||||
|
'@babel/core@<=7.29.0': ^7.29.6
|
||||||
|
'@hono/node-server@<1.19.15': ^1.19.15
|
||||||
|
'@hono/node-server@>=1.19.10 <2.1.3': ^2.1.3
|
||||||
|
'@modelcontextprotocol/sdk@<1.32.0': ^1.32.0
|
||||||
|
axios@>=1.0.0 <1.20.0: ^1.20.0
|
||||||
|
baseline-browser-mapping@>=2.0.0 <2.11.0: ^2.11.0
|
||||||
|
body-parser@>=2.0.0 <2.4.0: ^2.4.0
|
||||||
|
brace-expansion@<1.1.21: ^1.1.21
|
||||||
|
brace-expansion@>=3.0.0 <5.0.7: ^5.0.7
|
||||||
|
brace-expansion@>=4.0.0 <5.0.12: ^5.0.12
|
||||||
|
browserslist@<=4.28.6: ^4.28.7
|
||||||
|
fast-uri@>=3.0.0 <3.1.9: ^3.1.9
|
||||||
|
follow-redirects@>=1.16.0 <1.16.1: ^1.16.1
|
||||||
|
form-data@>=4.0.0 <4.0.6: ^4.0.6
|
||||||
|
hono@<4.13.7: ^4.13.7
|
||||||
|
hono@>=4.12.4 <4.13.11: ^4.13.11
|
||||||
|
ip-address@<=10.7.3: ^10.7.4
|
||||||
|
js-yaml@>=4.0.0 <4.3.2: ^4.3.2
|
||||||
|
nanoid@<3.3.18: ^3.3.18
|
||||||
|
postcss-selector-parser@>=7.0.0 <7.1.6: ^7.1.6
|
||||||
|
postcss@<=8.5.22: ^8.5.23
|
||||||
|
proxy-addr@>=1.1.0 <2.0.8: ^2.0.8
|
||||||
|
qs@>=2.2.5 <6.16.0: ^6.16.0
|
||||||
|
qs@>=6.7.0 <=6.16.0: ^6.16.1
|
||||||
|
react-router@>=6.0.0 <7.18.0: ^7.18.0
|
||||||
|
react-router@>=7.12.0 <7.18.2: ^7.18.2
|
||||||
|
source-map-js@>=1.0.0 <1.2.2: ^1.2.2
|
||||||
|
vite@>=8.0.0 <=8.1.5: ^8.1.6
|
||||||
|
zod@<4.6.6: ^4.6.6
|
||||||
@@ -154,28 +154,39 @@ export function CollectionDetailsSkeleton() {
|
|||||||
export function EntryDetailsSkeleton() {
|
export function EntryDetailsSkeleton() {
|
||||||
return (
|
return (
|
||||||
<div className="animate-in fade-in duration-300">
|
<div className="animate-in fade-in duration-300">
|
||||||
<div className="h-52 -mx-6 -mt-6 bg-muted animate-pulse rounded-b-lg" />
|
<div className="relative -mx-4 -mt-4 bg-muted/40 md:-mx-6 md:-mt-6">
|
||||||
<div className="max-w-4xl mx-auto flex gap-8 -mt-24">
|
<div className="mx-auto flex max-w-6xl flex-col items-center gap-6 px-4 pb-8 pt-28 sm:flex-row sm:items-end sm:gap-8 sm:pt-44 md:px-6">
|
||||||
<div className="w-44 shrink-0 space-y-3">
|
<Skeleton className="aspect-[2/3] w-40 shrink-0 rounded-xl sm:w-52 lg:w-60" />
|
||||||
<Skeleton className="aspect-[2/3] w-full rounded-xl" />
|
<div className="w-full flex-1 space-y-4">
|
||||||
<Skeleton className="h-9 w-full rounded-lg" />
|
<Skeleton className="h-5 w-24 rounded-full" />
|
||||||
<Skeleton className="h-9 w-full rounded-lg" />
|
<Skeleton className="h-12 w-3/4 max-w-md" />
|
||||||
<Skeleton className="h-9 w-full rounded-lg" />
|
<Skeleton className="h-4 w-48" />
|
||||||
</div>
|
<div className="flex gap-1.5">
|
||||||
<div className="flex-1 space-y-4 pt-24">
|
<Skeleton className="h-6 w-16 rounded-full" />
|
||||||
<Skeleton className="h-9 w-72" />
|
<Skeleton className="h-6 w-20 rounded-full" />
|
||||||
<Skeleton className="h-4 w-32" />
|
<Skeleton className="h-6 w-14 rounded-full" />
|
||||||
<div className="flex gap-2">
|
|
||||||
<Skeleton className="h-5 w-12" />
|
|
||||||
<Skeleton className="h-5 w-16" />
|
|
||||||
<Skeleton className="h-5 w-20" />
|
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<Skeleton className="h-8 w-24 rounded-full" />
|
<Skeleton className="h-11 w-36 rounded-md" />
|
||||||
<Skeleton className="h-8 w-24 rounded-full" />
|
<Skeleton className="h-11 w-28 rounded-md" />
|
||||||
<Skeleton className="h-8 w-20 rounded-full" />
|
<Skeleton className="h-11 w-11 rounded-full" />
|
||||||
|
<Skeleton className="h-11 w-11 rounded-full" />
|
||||||
</div>
|
</div>
|
||||||
<Skeleton className="h-20 w-full" />
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="mx-auto mt-4 grid max-w-6xl gap-10 lg:grid-cols-[minmax(0,1fr)_300px]">
|
||||||
|
<div className="space-y-3">
|
||||||
|
<Skeleton className="h-6 w-28" />
|
||||||
|
<Skeleton className="h-24 w-full" />
|
||||||
|
</div>
|
||||||
|
<div className="space-y-4">
|
||||||
|
<div className="grid grid-cols-3 gap-2">
|
||||||
|
<Skeleton className="h-20 rounded-xl" />
|
||||||
|
<Skeleton className="h-20 rounded-xl" />
|
||||||
|
<Skeleton className="h-20 rounded-xl" />
|
||||||
|
</div>
|
||||||
|
<Skeleton className="h-40 rounded-xl" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -137,3 +137,24 @@ export function getYear(dateStr: string | null): string {
|
|||||||
if (!dateStr) return "";
|
if (!dateStr) return "";
|
||||||
return new Date(dateStr).getFullYear().toString();
|
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;
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect, type ReactNode } from "react";
|
||||||
import { useParams, Link, useNavigate } from "react-router-dom";
|
import { useParams, Link, useNavigate } from "react-router-dom";
|
||||||
import {
|
import {
|
||||||
useEntry,
|
useEntry,
|
||||||
@@ -10,9 +10,7 @@ import { useEntrySeenByEntry, useDeleteEntrySeen } from "@/hooks/useEntrySeen";
|
|||||||
import { useCollections } from "@/hooks/useCollections";
|
import { useCollections } from "@/hooks/useCollections";
|
||||||
import { useLibraryStore } from "@/stores/useLibraryStore";
|
import { useLibraryStore } from "@/stores/useLibraryStore";
|
||||||
import { useCommandPaletteStore } from "@/stores/useCommandPaletteStore";
|
import { useCommandPaletteStore } from "@/stores/useCommandPaletteStore";
|
||||||
import { Badge } from "@/components/ui/badge";
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Separator } from "@/components/ui/separator";
|
|
||||||
import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
|
import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
@@ -36,17 +34,19 @@ import {
|
|||||||
ExternalLink,
|
ExternalLink,
|
||||||
Play,
|
Play,
|
||||||
BookmarkCheck,
|
BookmarkCheck,
|
||||||
|
Film,
|
||||||
|
Tv,
|
||||||
|
Clock,
|
||||||
|
CalendarDays,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import {
|
import {
|
||||||
Tooltip,
|
Tooltip,
|
||||||
TooltipContent,
|
TooltipContent,
|
||||||
TooltipProvider,
|
|
||||||
TooltipTrigger,
|
TooltipTrigger,
|
||||||
} from "@/components/ui/tooltip";
|
} from "@/components/ui/tooltip";
|
||||||
import { CastList } from "@/components/entries/CastList";
|
import { CastList } from "@/components/entries/CastList";
|
||||||
import { SeasonsContainer } from "@/components/entries/SeasonsContainer";
|
import { SeasonsContainer } from "@/components/entries/SeasonsContainer";
|
||||||
import { StreamingSection } from "@/components/streaming/StreamingSection";
|
import { StreamingSection } from "@/components/streaming/StreamingSection";
|
||||||
// EpisodeWatchHistory is available for future use
|
|
||||||
import { EntrySettingsDialog } from "@/components/dialogs/EntrySettingsDialog";
|
import { EntrySettingsDialog } from "@/components/dialogs/EntrySettingsDialog";
|
||||||
import { EntrySeenDialog } from "@/components/dialogs/EntrySeenDialog";
|
import { EntrySeenDialog } from "@/components/dialogs/EntrySeenDialog";
|
||||||
import { EntryMediaDialog } from "@/components/dialogs/EntryMediaDialog";
|
import { EntryMediaDialog } from "@/components/dialogs/EntryMediaDialog";
|
||||||
@@ -78,29 +78,29 @@ const WATCH_STATUSES = [
|
|||||||
value: "plan_to_watch",
|
value: "plan_to_watch",
|
||||||
label: "Plan to Watch",
|
label: "Plan to Watch",
|
||||||
color:
|
color:
|
||||||
"bg-slate-500/15 border-slate-500/30 text-slate-600 dark:text-slate-400",
|
"bg-slate-500/15 border-slate-500/30 text-slate-600 dark:text-slate-300",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "watching",
|
value: "watching",
|
||||||
label: "Watching",
|
label: "Watching",
|
||||||
color: "bg-blue-500/15 border-blue-500/30 text-blue-600 dark:text-blue-400",
|
color: "bg-blue-500/15 border-blue-500/30 text-blue-600 dark:text-blue-300",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "completed",
|
value: "completed",
|
||||||
label: "Completed",
|
label: "Completed",
|
||||||
color:
|
color:
|
||||||
"bg-green-500/15 border-green-500/30 text-green-600 dark:text-green-400",
|
"bg-green-500/15 border-green-500/30 text-green-600 dark:text-green-300",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "on_hold",
|
value: "on_hold",
|
||||||
label: "On Hold",
|
label: "On Hold",
|
||||||
color:
|
color:
|
||||||
"bg-amber-500/15 border-amber-500/30 text-amber-600 dark:text-amber-400",
|
"bg-amber-500/15 border-amber-500/30 text-amber-600 dark:text-amber-300",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "dropped",
|
value: "dropped",
|
||||||
label: "Dropped",
|
label: "Dropped",
|
||||||
color: "bg-red-500/15 border-red-500/30 text-red-600 dark:text-red-400",
|
color: "bg-red-500/15 border-red-500/30 text-red-600 dark:text-red-300",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -167,92 +167,239 @@ export function EntryDetailsPage() {
|
|||||||
const director = credits.find(
|
const director = credits.find(
|
||||||
(c) => c.cast_type === "crew" && c.job === "Director",
|
(c) => c.cast_type === "crew" && c.job === "Director",
|
||||||
);
|
);
|
||||||
|
const watchStatus = e.is_tvseries
|
||||||
|
? getWatchStatusInfo(e.watch_status)
|
||||||
|
: undefined;
|
||||||
|
const userRating = e.entryRatings?.user_rating ?? 0;
|
||||||
|
const lastSeen =
|
||||||
|
watchHistory
|
||||||
|
.map((wh) => wh.date_seen)
|
||||||
|
.filter(Boolean)
|
||||||
|
.sort()
|
||||||
|
.at(-1) ?? null;
|
||||||
|
|
||||||
const toggleFavorite = () => {
|
const toggleFavorite = () => {
|
||||||
updateEntry.mutate({ id: e.id, data: { favorit: !e.favorit } });
|
updateEntry.mutate({ id: e.id, data: { favorit: !e.favorit } });
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="animate-page-enter">
|
||||||
{/* Backdrop banner */}
|
{/* ── Hero ── */}
|
||||||
<div className="relative -mx-6 -mt-6 h-52 overflow-hidden">
|
<section className="relative -mx-4 -mt-4 md:-mx-6 md:-mt-6">
|
||||||
|
<div className="absolute inset-0 overflow-hidden">
|
||||||
{backdrop ? (
|
{backdrop ? (
|
||||||
<img
|
<img
|
||||||
src={backdrop}
|
src={backdrop}
|
||||||
alt=""
|
alt=""
|
||||||
className="h-full w-full object-cover opacity-25 blur-sm scale-105"
|
className="h-full w-full object-cover object-top"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="h-full w-full bg-linear-to-br from-primary/15 to-primary/5" />
|
<div className="h-full w-full bg-linear-to-br from-primary/30 via-primary/10 to-background" />
|
||||||
)}
|
)}
|
||||||
<div className="absolute inset-0 bg-linear-to-t from-background via-background/60 to-transparent" />
|
{/* Fade into the page at the bottom and behind the text on the left */}
|
||||||
|
<div className="absolute inset-0 bg-linear-to-t from-background via-background/75 to-background/10" />
|
||||||
|
<div className="absolute inset-0 bg-linear-to-r from-background/90 via-background/40 to-transparent" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Main content */}
|
<div className="relative mx-auto max-w-6xl px-4 pb-8 pt-28 md:px-6 sm:pt-44">
|
||||||
<div className="mx-auto max-w-4xl">
|
<div className="flex flex-col items-center gap-6 sm:flex-row sm:items-end sm:gap-8">
|
||||||
{/* Action buttons — top right. The row overlaps the title below, so
|
<button
|
||||||
only the button itself takes pointer events. */}
|
type="button"
|
||||||
<div className="flex justify-end gap-1 -mt-10 relative z-10 mb-2 pointer-events-none">
|
onClick={() => setShowPosterDialog(true)}
|
||||||
|
className="group relative w-40 shrink-0 cursor-zoom-in rounded-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring sm:w-52 lg:w-60"
|
||||||
|
aria-label="View full-size poster"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src={poster}
|
||||||
|
alt={e.title}
|
||||||
|
className="aspect-2/3 w-full rounded-xl object-cover shadow-2xl shadow-black/50 ring-1 ring-white/10 transition-transform duration-300 group-hover:scale-[1.02]"
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div className="min-w-0 flex-1 space-y-4 text-center sm:text-left">
|
||||||
|
{/* Eyebrow: type + status */}
|
||||||
|
<div className="flex flex-wrap items-center justify-center gap-2 sm:justify-start">
|
||||||
|
<span className="inline-flex items-center gap-1.5 rounded-full border border-border/60 bg-background/60 px-2.5 py-0.5 text-xs font-medium uppercase tracking-wider text-muted-foreground backdrop-blur">
|
||||||
|
{e.is_tvseries ? (
|
||||||
|
<Tv className="h-3 w-3" />
|
||||||
|
) : (
|
||||||
|
<Film className="h-3 w-3" />
|
||||||
|
)}
|
||||||
|
{e.is_tvseries ? "TV Series" : "Movie"}
|
||||||
|
</span>
|
||||||
|
{e.is_tvseries && e.status && (
|
||||||
|
<span className="rounded-full border border-border/60 bg-background/60 px-2.5 py-0.5 text-xs font-medium text-muted-foreground backdrop-blur">
|
||||||
|
{e.status}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{e.is_tvseries && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => setShowStatusDialog(true)}
|
||||||
|
className={`inline-flex items-center gap-1 rounded-full border px-2.5 py-0.5 text-xs font-medium transition-colors ${
|
||||||
|
watchStatus?.color ??
|
||||||
|
"border-dashed border-border text-muted-foreground hover:text-foreground"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<BookmarkCheck className="h-3 w-3" />
|
||||||
|
{watchStatus?.label ?? "Set status"}
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-1.5">
|
||||||
|
<h1 className="select-text text-4xl font-extrabold leading-[1.05] tracking-tight text-balance sm:text-5xl">
|
||||||
|
{e.title}
|
||||||
|
</h1>
|
||||||
|
{e.original_title && e.original_title !== e.title && (
|
||||||
|
<p className="select-text text-sm text-muted-foreground italic">
|
||||||
|
{e.original_title}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Meta */}
|
||||||
|
<div className="flex flex-wrap items-center justify-center gap-x-3 gap-y-1 text-sm text-muted-foreground sm:justify-start">
|
||||||
|
{e.release_date && (
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger
|
||||||
|
render={
|
||||||
|
<span className="cursor-default font-medium text-foreground/90" />
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{getYear(e.release_date)}
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent>
|
||||||
|
{formatDate(e.release_date)}
|
||||||
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
|
{e.runtime && !e.is_tvseries && (
|
||||||
|
<MetaItem>{formatRuntime(e.runtime)}</MetaItem>
|
||||||
|
)}
|
||||||
|
{e.is_tvseries && seasons && seasons.length > 0 && (
|
||||||
|
<MetaItem>
|
||||||
|
{seasons.length}{" "}
|
||||||
|
{seasons.length === 1 ? "season" : "seasons"}
|
||||||
|
</MetaItem>
|
||||||
|
)}
|
||||||
|
{director?.people?.name && (
|
||||||
|
<MetaItem>
|
||||||
|
Directed by{" "}
|
||||||
|
<Link
|
||||||
|
to={`/people/${director.people_id}`}
|
||||||
|
className="font-medium text-foreground hover:underline"
|
||||||
|
>
|
||||||
|
{director.people.name}
|
||||||
|
</Link>
|
||||||
|
</MetaItem>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Genres */}
|
||||||
|
{e.genres && e.genres.length > 0 && (
|
||||||
|
<div className="flex flex-wrap justify-center gap-1.5 sm:justify-start">
|
||||||
|
{e.genres.map((g) => (
|
||||||
|
<Link
|
||||||
|
key={g.id}
|
||||||
|
to={`/library?genre=${encodeURIComponent(g.name)}`}
|
||||||
|
className="rounded-full bg-foreground/5 px-3 py-1 text-xs font-medium text-foreground/80 ring-1 ring-border/60 backdrop-blur transition-colors hover:bg-foreground/10 hover:text-foreground"
|
||||||
|
>
|
||||||
|
{g.name}
|
||||||
|
</Link>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Actions */}
|
||||||
|
<div className="flex flex-wrap items-center justify-center gap-2 pt-1 sm:justify-start">
|
||||||
|
<StreamingSection entry={e} seasons={seasons} />
|
||||||
|
<a
|
||||||
|
href={`https://www.youtube.com/results?search_query=${encodeURIComponent(e.title + " official trailer")}`}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
className="inline-flex h-11 items-center gap-2 rounded-md border border-border/60 bg-background/60 px-5 text-sm font-medium backdrop-blur transition-colors hover:bg-accent"
|
||||||
|
>
|
||||||
|
<Play className="h-4 w-4" />
|
||||||
|
Trailer
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<div className="flex items-center gap-1.5">
|
||||||
|
<IconAction
|
||||||
|
label="Mark as watched"
|
||||||
|
onClick={() => setShowSeenDialog(true)}
|
||||||
|
>
|
||||||
|
<Eye className="h-4 w-4" />
|
||||||
|
</IconAction>
|
||||||
|
<IconAction
|
||||||
|
label={userRating > 0 ? "Change rating" : "Rate this"}
|
||||||
|
onClick={() => setShowRatingDialog(true)}
|
||||||
|
active={userRating > 0}
|
||||||
|
>
|
||||||
|
<Star
|
||||||
|
className={`h-4 w-4 ${userRating > 0 ? "fill-yellow-400 text-yellow-400" : ""}`}
|
||||||
|
/>
|
||||||
|
</IconAction>
|
||||||
|
<IconAction
|
||||||
|
label={
|
||||||
|
e.favorit ? "Remove from favorites" : "Add to favorites"
|
||||||
|
}
|
||||||
|
onClick={toggleFavorite}
|
||||||
|
disabled={updateEntry.isPending}
|
||||||
|
active={e.favorit}
|
||||||
|
>
|
||||||
|
<Heart
|
||||||
|
className={`h-4 w-4 ${e.favorit ? "fill-red-500 text-red-500" : ""}`}
|
||||||
|
/>
|
||||||
|
</IconAction>
|
||||||
|
<IconAction
|
||||||
|
label="Add to collection"
|
||||||
|
onClick={() => setShowCollectionDialog(true)}
|
||||||
|
>
|
||||||
|
<FolderPlus className="h-4 w-4" />
|
||||||
|
</IconAction>
|
||||||
|
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger
|
||||||
|
render={
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="outline"
|
||||||
size="icon"
|
size="icon-lg"
|
||||||
className="h-9 w-9 pointer-events-auto"
|
className="h-11 w-11 rounded-full border-border/60 bg-background/60 backdrop-blur"
|
||||||
|
aria-label="More actions"
|
||||||
|
/>
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<MoreHorizontal className="h-4 w-4" />
|
<MoreHorizontal className="h-4 w-4" />
|
||||||
</Button>
|
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
<DropdownMenuContent align="end" className="w-56">
|
<DropdownMenuContent align="end" className="w-56">
|
||||||
{/* Watch & Rate */}
|
{e.is_tvseries ? (
|
||||||
<DropdownMenuItem onClick={() => setShowSeenDialog(true)}>
|
<DropdownMenuItem
|
||||||
<Eye className="mr-2 h-4 w-4" />
|
onClick={() => setShowStatusDialog(true)}
|
||||||
Mark as watched
|
>
|
||||||
</DropdownMenuItem>
|
|
||||||
<DropdownMenuItem onClick={() => setShowRatingDialog(true)}>
|
|
||||||
<Star className="mr-2 h-4 w-4" />
|
|
||||||
Rate this
|
|
||||||
</DropdownMenuItem>
|
|
||||||
{e.is_tvseries && <DropdownMenuSeparator />}
|
|
||||||
{e.is_tvseries && (
|
|
||||||
<DropdownMenuItem onClick={() => setShowStatusDialog(true)}>
|
|
||||||
<BookmarkCheck className="mr-2 h-4 w-4" />
|
<BookmarkCheck className="mr-2 h-4 w-4" />
|
||||||
Set Status
|
Set status
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
)}
|
) : (
|
||||||
{!e.is_tvseries && (
|
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
onClick={() => setShowWatchHistoryDialog(true)}
|
onClick={() => setShowWatchHistoryDialog(true)}
|
||||||
>
|
>
|
||||||
<History className="mr-2 h-4 w-4" />
|
<History className="mr-2 h-4 w-4" />
|
||||||
Watch History
|
Watch history
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
)}
|
)}
|
||||||
<DropdownMenuSeparator />
|
|
||||||
{/* Organize */}
|
|
||||||
<DropdownMenuItem
|
|
||||||
onClick={toggleFavorite}
|
|
||||||
disabled={updateEntry.isPending}
|
|
||||||
>
|
|
||||||
<Heart
|
|
||||||
className={`mr-2 h-4 w-4 ${e.favorit ? "fill-current" : ""}`}
|
|
||||||
/>
|
|
||||||
{e.favorit ? "Unfavorite" : "Favorite"}
|
|
||||||
</DropdownMenuItem>
|
|
||||||
<DropdownMenuItem onClick={() => setShowCollectionDialog(true)}>
|
|
||||||
<FolderPlus className="mr-2 h-4 w-4" />
|
|
||||||
Add to collection
|
|
||||||
</DropdownMenuItem>
|
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
updateEntry.mutate({ id: e.id, data: { hidden: !e.hidden } })
|
updateEntry.mutate({
|
||||||
|
id: e.id,
|
||||||
|
data: { hidden: !e.hidden },
|
||||||
|
})
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<EyeOff className="mr-2 h-4 w-4" />
|
<EyeOff className="mr-2 h-4 w-4" />
|
||||||
{e.hidden ? "Unhide" : "Hide"}
|
{e.hidden ? "Unhide" : "Hide"}
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
<DropdownMenuSeparator />
|
<DropdownMenuSeparator />
|
||||||
{/* Manage */}
|
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
onClick={() => refreshEntry.mutate(e.id)}
|
onClick={() => refreshEntry.mutate(e.id)}
|
||||||
disabled={refreshEntry.isPending}
|
disabled={refreshEntry.isPending}
|
||||||
@@ -260,9 +407,13 @@ export function EntryDetailsPage() {
|
|||||||
<RefreshCw
|
<RefreshCw
|
||||||
className={`mr-2 h-4 w-4 ${refreshEntry.isPending ? "animate-spin" : ""}`}
|
className={`mr-2 h-4 w-4 ${refreshEntry.isPending ? "animate-spin" : ""}`}
|
||||||
/>
|
/>
|
||||||
{refreshEntry.isPending ? "Refreshing..." : "Refresh details"}
|
{refreshEntry.isPending
|
||||||
|
? "Refreshing..."
|
||||||
|
: "Refresh details"}
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
<DropdownMenuItem onClick={() => setShowMediaDialog(true)}>
|
<DropdownMenuItem
|
||||||
|
onClick={() => setShowMediaDialog(true)}
|
||||||
|
>
|
||||||
<ImageIcon className="mr-2 h-4 w-4" />
|
<ImageIcon className="mr-2 h-4 w-4" />
|
||||||
Manage media
|
Manage media
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
@@ -271,7 +422,6 @@ export function EntryDetailsPage() {
|
|||||||
Settings
|
Settings
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
<DropdownMenuSeparator />
|
<DropdownMenuSeparator />
|
||||||
{/* Danger */}
|
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
className="text-destructive focus:text-destructive"
|
className="text-destructive focus:text-destructive"
|
||||||
onClick={() => setShowDeleteConfirm(true)}
|
onClick={() => setShowDeleteConfirm(true)}
|
||||||
@@ -282,296 +432,139 @@ export function EntryDetailsPage() {
|
|||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Two-column header: sticky poster | info */}
|
|
||||||
<div className="flex flex-col gap-6 relative items-start sm:flex-row sm:gap-8 sm:-mt-8">
|
|
||||||
{/* LEFT: Sticky poster */}
|
|
||||||
<div className="sm:sticky sm:top-20 w-32 sm:w-44 shrink-0 self-start mx-auto sm:mx-0">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={() => setShowPosterDialog(true)}
|
|
||||||
className="relative block w-full cursor-zoom-in rounded-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
||||||
aria-label="View full-size poster"
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
src={poster}
|
|
||||||
alt={e.title}
|
|
||||||
className="w-full aspect-2/3 rounded-xl object-cover shadow-2xl ring-1 ring-border/50"
|
|
||||||
/>
|
|
||||||
</button>
|
|
||||||
{/* External links */}
|
|
||||||
{e.entryIds && (
|
|
||||||
<div className="flex items-center justify-center gap-3 mt-3">
|
|
||||||
{e.entryIds.tmdb_id && (
|
|
||||||
<a
|
|
||||||
href={`https://www.themoviedb.org/${e.is_tvseries ? "tv" : "movie"}/${e.entryIds.tmdb_id}`}
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
className="inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors"
|
|
||||||
>
|
|
||||||
<ExternalLink className="h-3 w-3" />
|
|
||||||
TMDB
|
|
||||||
</a>
|
|
||||||
)}
|
|
||||||
{e.entryIds.imdb_id && (
|
|
||||||
<a
|
|
||||||
href={`https://www.imdb.com/title/${e.entryIds.imdb_id}`}
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
className="inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors"
|
|
||||||
>
|
|
||||||
<ExternalLink className="h-3 w-3" />
|
|
||||||
IMDb
|
|
||||||
</a>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* RIGHT: Entry info */}
|
|
||||||
<div className="flex-1 min-w-0 space-y-4">
|
|
||||||
{/* Title + director */}
|
|
||||||
<div className="space-y-1">
|
|
||||||
<h1 className="text-3xl font-bold leading-tight select-text">
|
|
||||||
{e.title}
|
|
||||||
</h1>
|
|
||||||
{director?.people?.name && (
|
|
||||||
<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>
|
</div>
|
||||||
|
|
||||||
{/* Meta */}
|
|
||||||
<div className="flex flex-wrap items-center gap-2 text-sm text-muted-foreground">
|
|
||||||
{e.release_date && (
|
|
||||||
<TooltipProvider>
|
|
||||||
<Tooltip>
|
|
||||||
<TooltipTrigger asChild>
|
|
||||||
<span className="cursor-default underline decoration-dotted">
|
|
||||||
{getYear(e.release_date)}
|
|
||||||
</span>
|
|
||||||
</TooltipTrigger>
|
|
||||||
<TooltipContent>
|
|
||||||
<p>{formatDate(e.release_date)}</p>
|
|
||||||
</TooltipContent>
|
|
||||||
</Tooltip>
|
|
||||||
</TooltipProvider>
|
|
||||||
)}
|
|
||||||
{e.is_tvseries && e.status && (
|
|
||||||
<>
|
|
||||||
<span>•</span>
|
|
||||||
<span>{e.status}</span>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{e.runtime && !e.is_tvseries && (
|
|
||||||
<>
|
|
||||||
<span>•</span>
|
|
||||||
<span>{formatRuntime(e.runtime)}</span>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{!e.is_tvseries && watchHistory.length > 0 && (
|
|
||||||
<>
|
|
||||||
<span>•</span>
|
|
||||||
{watchHistory.length === 1 ? (
|
|
||||||
<span>Seen {formatDate(watchHistory[0].date_seen)}</span>
|
|
||||||
) : (
|
|
||||||
<TooltipProvider>
|
|
||||||
<Tooltip>
|
|
||||||
<TooltipTrigger asChild>
|
|
||||||
<span className="cursor-default underline decoration-dotted">
|
|
||||||
Seen {watchHistory.length} times
|
|
||||||
</span>
|
|
||||||
</TooltipTrigger>
|
|
||||||
<TooltipContent>
|
|
||||||
<div className="space-y-0.5 text-xs">
|
|
||||||
{watchHistory.map((wh) => (
|
|
||||||
<p key={wh.id}>{formatDate(wh.date_seen)}</p>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</TooltipContent>
|
|
||||||
</Tooltip>
|
|
||||||
</TooltipProvider>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{!e.is_tvseries && watchHistory.length === 0 && (
|
|
||||||
<>
|
|
||||||
<span>•</span>
|
|
||||||
<button
|
|
||||||
className="inline-flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors underline decoration-dotted cursor-pointer"
|
|
||||||
onClick={() => setShowSeenDialog(true)}
|
|
||||||
>
|
|
||||||
<Eye className="h-3 w-3" />
|
|
||||||
Mark as watched
|
|
||||||
</button>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
{/* Genres */}
|
{/* ── Body ── */}
|
||||||
{e.genres && e.genres.length > 0 && (
|
<div className="mx-auto mt-4 grid max-w-6xl gap-10 lg:grid-cols-[minmax(0,1fr)_300px]">
|
||||||
<div className="flex flex-wrap gap-1.5">
|
<div className="min-w-0 space-y-10">
|
||||||
{e.genres.map((g) => (
|
|
||||||
<Link
|
|
||||||
key={g.id}
|
|
||||||
to={`/library?genre=${encodeURIComponent(g.name)}`}
|
|
||||||
>
|
|
||||||
<Badge
|
|
||||||
variant="outline"
|
|
||||||
className="text-xs cursor-pointer hover:bg-accent transition-colors"
|
|
||||||
>
|
|
||||||
{g.name}
|
|
||||||
</Badge>
|
|
||||||
</Link>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Ratings */}
|
|
||||||
<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 && (
|
|
||||||
<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>
|
|
||||||
)}
|
|
||||||
{/* Favorite pill */}
|
|
||||||
<TooltipProvider>
|
|
||||||
<Tooltip>
|
|
||||||
<TooltipTrigger asChild>
|
|
||||||
<button
|
|
||||||
onClick={toggleFavorite}
|
|
||||||
disabled={updateEntry.isPending}
|
|
||||||
className={`inline-flex items-center gap-1 rounded-full border px-3 py-1 text-sm font-medium transition-colors ${
|
|
||||||
e.favorit
|
|
||||||
? "bg-yellow-500/15 border-yellow-500/30 text-yellow-600 dark:text-yellow-400 hover:bg-yellow-500/25"
|
|
||||||
: "border-dashed border-border text-muted-foreground hover:border-yellow-500/40 hover:text-yellow-500"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
<Star
|
|
||||||
className={`h-3.5 w-3.5 ${e.favorit ? "fill-yellow-400 text-yellow-400" : ""}`}
|
|
||||||
/>
|
|
||||||
Favorit
|
|
||||||
</button>
|
|
||||||
</TooltipTrigger>
|
|
||||||
<TooltipContent>
|
|
||||||
<p>
|
|
||||||
{e.favorit ? "Remove from favorites" : "Add to favorites"}
|
|
||||||
</p>
|
|
||||||
</TooltipContent>
|
|
||||||
</Tooltip>
|
|
||||||
</TooltipProvider>
|
|
||||||
|
|
||||||
{/* Watch status pill — TV only */}
|
|
||||||
{e.is_tvseries &&
|
|
||||||
e.watch_status &&
|
|
||||||
(() => {
|
|
||||||
const info = getWatchStatusInfo(e.watch_status);
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
onClick={() => setShowStatusDialog(true)}
|
|
||||||
className={`inline-flex items-center gap-1 rounded-full border px-3 py-1 text-sm font-medium transition-colors cursor-pointer ${info?.color ?? ""}`}
|
|
||||||
>
|
|
||||||
<BookmarkCheck className="h-3.5 w-3.5" />
|
|
||||||
{info?.label}
|
|
||||||
</button>
|
|
||||||
);
|
|
||||||
})()}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Storyline */}
|
|
||||||
{e.storyline && (
|
{e.storyline && (
|
||||||
<p className="text-sm text-muted-foreground leading-relaxed max-w-prose">
|
<Section title="Overview">
|
||||||
|
<p className="select-text max-w-prose text-[15px] leading-relaxed text-foreground/85">
|
||||||
{e.storyline}
|
{e.storyline}
|
||||||
</p>
|
</p>
|
||||||
|
</Section>
|
||||||
)}
|
)}
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Sections */}
|
|
||||||
<div className="mt-10 space-y-8">
|
|
||||||
{/* Streaming player + Trailer */}
|
|
||||||
<div className="flex flex-wrap items-center justify-center gap-2">
|
|
||||||
<StreamingSection entry={e} seasons={seasons} />
|
|
||||||
<a
|
|
||||||
href={`https://www.youtube.com/results?search_query=${encodeURIComponent(e.title + " official trailer")}`}
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
className="inline-flex items-center gap-2 h-11 px-6 text-sm font-medium rounded-md border border-input bg-background hover:bg-accent hover:text-accent-foreground transition-colors"
|
|
||||||
>
|
|
||||||
<Play className="h-4 w-4" />
|
|
||||||
Watch Trailer
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{credits.length > 0 && (
|
{credits.length > 0 && (
|
||||||
<>
|
|
||||||
<Separator />
|
|
||||||
<CastList
|
<CastList
|
||||||
credits={credits}
|
credits={credits}
|
||||||
entryId={e.id}
|
entryId={e.id}
|
||||||
isTvSeries={e.is_tvseries}
|
isTvSeries={e.is_tvseries}
|
||||||
maxItems={12}
|
maxItems={12}
|
||||||
/>
|
/>
|
||||||
</>
|
)}
|
||||||
|
|
||||||
|
{e.is_tvseries && seasons && seasons.length > 0 && (
|
||||||
|
<SeasonsContainer seasons={seasons} entryId={e.id} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<EntryCollectionsSection entryId={e.id} />
|
<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>
|
</div>
|
||||||
|
|
||||||
|
{/* ── Sidebar ── */}
|
||||||
|
<aside className="space-y-4 lg:sticky lg:top-6 lg:self-start">
|
||||||
|
<div className="grid grid-cols-3 gap-2">
|
||||||
|
<RatingTile
|
||||||
|
label="IMDb"
|
||||||
|
value={
|
||||||
|
e.entryRatings?.imdb_rating
|
||||||
|
? e.entryRatings.imdb_rating.toFixed(1)
|
||||||
|
: null
|
||||||
|
}
|
||||||
|
accent="text-yellow-500"
|
||||||
|
/>
|
||||||
|
<RatingTile
|
||||||
|
label="TMDB"
|
||||||
|
value={
|
||||||
|
e.entryRatings?.tmdb_rating
|
||||||
|
? e.entryRatings.tmdb_rating.toFixed(1)
|
||||||
|
: null
|
||||||
|
}
|
||||||
|
accent="text-sky-500"
|
||||||
|
/>
|
||||||
|
<RatingTile
|
||||||
|
label="You"
|
||||||
|
value={userRating > 0 ? String(userRating) : null}
|
||||||
|
accent="text-primary"
|
||||||
|
emptyLabel="Rate"
|
||||||
|
onClick={() => setShowRatingDialog(true)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="rounded-xl border border-border/60 bg-card/50 p-4">
|
||||||
|
<h3 className="mb-3 text-xs font-semibold uppercase tracking-wider text-muted-foreground">
|
||||||
|
Details
|
||||||
|
</h3>
|
||||||
|
<dl className="space-y-2.5 text-sm">
|
||||||
|
{e.release_date && (
|
||||||
|
<DetailRow icon={<CalendarDays />} label="Released">
|
||||||
|
{formatDate(e.release_date)}
|
||||||
|
</DetailRow>
|
||||||
|
)}
|
||||||
|
{e.runtime && !e.is_tvseries && (
|
||||||
|
<DetailRow icon={<Clock />} label="Runtime">
|
||||||
|
{formatRuntime(e.runtime)}
|
||||||
|
</DetailRow>
|
||||||
|
)}
|
||||||
|
{e.is_tvseries && e.networks && e.networks.length > 0 && (
|
||||||
|
<DetailRow icon={<Tv />} label="Network">
|
||||||
|
{e.networks.map((n) => n.name).join(", ")}
|
||||||
|
</DetailRow>
|
||||||
|
)}
|
||||||
|
{e.country && (
|
||||||
|
<DetailRow icon={<Film />} label="Country">
|
||||||
|
{e.country}
|
||||||
|
</DetailRow>
|
||||||
|
)}
|
||||||
|
{!e.is_tvseries && (
|
||||||
|
<DetailRow icon={<Eye />} label="Watched">
|
||||||
|
{watchHistory.length > 0 ? (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => setShowWatchHistoryDialog(true)}
|
||||||
|
className="text-right hover:underline"
|
||||||
|
>
|
||||||
|
{watchHistory.length === 1
|
||||||
|
? formatDate(lastSeen)
|
||||||
|
: `${watchHistory.length}× · last ${formatDate(lastSeen)}`}
|
||||||
|
</button>
|
||||||
|
) : (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => setShowSeenDialog(true)}
|
||||||
|
className="text-muted-foreground hover:text-foreground hover:underline"
|
||||||
|
>
|
||||||
|
Not yet — mark
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</DetailRow>
|
||||||
|
)}
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
{(e.entryIds?.tmdb_id || e.entryIds?.imdb_id) && (
|
||||||
|
<div className="mt-4 flex gap-2 border-t border-border/60 pt-4">
|
||||||
|
{e.entryIds?.tmdb_id && (
|
||||||
|
<ExternalChip
|
||||||
|
href={`https://www.themoviedb.org/${e.is_tvseries ? "tv" : "movie"}/${e.entryIds.tmdb_id}`}
|
||||||
|
>
|
||||||
|
TMDB
|
||||||
|
</ExternalChip>
|
||||||
|
)}
|
||||||
|
{e.entryIds?.imdb_id && (
|
||||||
|
<ExternalChip
|
||||||
|
href={`https://www.imdb.com/title/${e.entryIds.imdb_id}`}
|
||||||
|
>
|
||||||
|
IMDb
|
||||||
|
</ExternalChip>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Dialogs */}
|
{/* Dialogs */}
|
||||||
@@ -698,6 +691,149 @@ export function EntryDetailsPage() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ---------- Small building blocks ---------- */
|
||||||
|
|
||||||
|
function MetaItem({ children }: { children: ReactNode }) {
|
||||||
|
return (
|
||||||
|
<span className="inline-flex items-center gap-3">
|
||||||
|
<span className="h-1 w-1 rounded-full bg-muted-foreground/50" />
|
||||||
|
<span>{children}</span>
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function IconAction({
|
||||||
|
label,
|
||||||
|
onClick,
|
||||||
|
disabled,
|
||||||
|
active,
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
label: string;
|
||||||
|
onClick: () => void;
|
||||||
|
disabled?: boolean;
|
||||||
|
active?: boolean;
|
||||||
|
children: ReactNode;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger
|
||||||
|
render={
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="icon-lg"
|
||||||
|
onClick={onClick}
|
||||||
|
disabled={disabled}
|
||||||
|
aria-label={label}
|
||||||
|
aria-pressed={active}
|
||||||
|
className={`h-11 w-11 rounded-full border-border/60 bg-background/60 backdrop-blur ${active ? "border-foreground/20 bg-accent" : ""}`}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent>{label}</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function Section({ title, children }: { title: string; children: ReactNode }) {
|
||||||
|
return (
|
||||||
|
<section className="space-y-3">
|
||||||
|
<h3 className="text-lg font-semibold">{title}</h3>
|
||||||
|
{children}
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function RatingTile({
|
||||||
|
label,
|
||||||
|
value,
|
||||||
|
accent,
|
||||||
|
emptyLabel = "—",
|
||||||
|
onClick,
|
||||||
|
}: {
|
||||||
|
label: string;
|
||||||
|
value: string | null;
|
||||||
|
accent: string;
|
||||||
|
emptyLabel?: string;
|
||||||
|
onClick?: () => void;
|
||||||
|
}) {
|
||||||
|
const content = (
|
||||||
|
<>
|
||||||
|
<span className="text-[11px] font-semibold uppercase tracking-wider text-muted-foreground">
|
||||||
|
{label}
|
||||||
|
</span>
|
||||||
|
{value ? (
|
||||||
|
<span className="flex items-baseline gap-0.5">
|
||||||
|
<span className={`text-2xl font-bold tabular-nums ${accent}`}>
|
||||||
|
{value}
|
||||||
|
</span>
|
||||||
|
<span className="text-xs text-muted-foreground">/10</span>
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
<span className="text-2xl font-bold text-muted-foreground/40">
|
||||||
|
{emptyLabel}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
const className =
|
||||||
|
"flex flex-col items-center gap-1 rounded-xl border border-border/60 bg-card/50 px-2 py-3";
|
||||||
|
|
||||||
|
return onClick ? (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={onClick}
|
||||||
|
className={`${className} transition-colors hover:bg-accent`}
|
||||||
|
>
|
||||||
|
{content}
|
||||||
|
</button>
|
||||||
|
) : (
|
||||||
|
<div className={className}>{content}</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function DetailRow({
|
||||||
|
icon,
|
||||||
|
label,
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
icon: ReactNode;
|
||||||
|
label: string;
|
||||||
|
children: ReactNode;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<div className="flex items-start justify-between gap-4">
|
||||||
|
<dt className="flex items-center gap-2 text-muted-foreground [&_svg]:h-3.5 [&_svg]:w-3.5">
|
||||||
|
{icon}
|
||||||
|
{label}
|
||||||
|
</dt>
|
||||||
|
<dd className="text-right font-medium">{children}</dd>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ExternalChip({
|
||||||
|
href,
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
href: string;
|
||||||
|
children: ReactNode;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<a
|
||||||
|
href={href}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
className="inline-flex items-center gap-1.5 rounded-md border border-border/60 px-2.5 py-1 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"
|
||||||
|
>
|
||||||
|
<ExternalLink className="h-3 w-3" />
|
||||||
|
{children}
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/* ---------- Collections section ---------- */
|
/* ---------- Collections section ---------- */
|
||||||
function EntryCollectionsSection({ entryId }: { entryId: number }) {
|
function EntryCollectionsSection({ entryId }: { entryId: number }) {
|
||||||
const { data: allCollections = [], isLoading } = useCollections();
|
const { data: allCollections = [], isLoading } = useCollections();
|
||||||
@@ -709,32 +845,29 @@ function EntryCollectionsSection({ entryId }: { entryId: number }) {
|
|||||||
if (isLoading || collections.length === 0) return null;
|
if (isLoading || collections.length === 0) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<Section title="In Collections">
|
||||||
<Separator />
|
|
||||||
<div className="space-y-3">
|
|
||||||
<h3 className="text-lg font-semibold">In Collections</h3>
|
|
||||||
<ScrollArea className="w-full">
|
<ScrollArea className="w-full">
|
||||||
<div className="flex gap-4 pb-4">
|
<div className="flex gap-4 pb-4">
|
||||||
{collections.map((col: Collection) => (
|
{collections.map((col: Collection) => (
|
||||||
<Link
|
<Link
|
||||||
key={col.id}
|
key={col.id}
|
||||||
to={`/collections/${col.id}`}
|
to={`/collections/${col.id}`}
|
||||||
className="group shrink-0 w-56 overflow-hidden rounded-lg relative block"
|
className="group relative block w-56 shrink-0 overflow-hidden rounded-xl ring-1 ring-border/60"
|
||||||
>
|
>
|
||||||
<div className="aspect-video w-full overflow-hidden bg-muted rounded-lg">
|
<div className="aspect-video w-full overflow-hidden bg-muted">
|
||||||
<img
|
<img
|
||||||
src={getCollectionBackdropUrl(col)}
|
src={getCollectionBackdropUrl(col)}
|
||||||
alt={col.name}
|
alt={col.name}
|
||||||
className="h-full w-full object-cover transition-transform group-hover:scale-105"
|
className="h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="absolute inset-0 bg-linear-to-t from-black/70 via-black/20 to-transparent rounded-lg" />
|
<div className="absolute inset-0 bg-linear-to-t from-black/80 via-black/20 to-transparent" />
|
||||||
<div className="absolute bottom-0 left-0 right-0 p-3">
|
<div className="absolute bottom-0 left-0 right-0 p-3">
|
||||||
<p className="text-sm font-medium text-white line-clamp-2 leading-tight">
|
<p className="line-clamp-2 text-sm font-semibold leading-tight text-white">
|
||||||
{col.name}
|
{col.name}
|
||||||
</p>
|
</p>
|
||||||
{col.entries && (
|
{col.entries && (
|
||||||
<p className="text-xs text-white/70 mt-0.5">
|
<p className="mt-0.5 text-xs text-white/70">
|
||||||
{col.entries.length}{" "}
|
{col.entries.length}{" "}
|
||||||
{col.entries.length === 1 ? "title" : "titles"}
|
{col.entries.length === 1 ? "title" : "titles"}
|
||||||
</p>
|
</p>
|
||||||
@@ -745,7 +878,6 @@ function EntryCollectionsSection({ entryId }: { entryId: number }) {
|
|||||||
</div>
|
</div>
|
||||||
<ScrollBar orientation="horizontal" />
|
<ScrollBar orientation="horizontal" />
|
||||||
</ScrollArea>
|
</ScrollArea>
|
||||||
</div>
|
</Section>
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -8,8 +8,13 @@ import { Skeleton } from "@/components/ui/skeleton";
|
|||||||
import { Switch } from "@/components/ui/switch";
|
import { Switch } from "@/components/ui/switch";
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||||
|
import {
|
||||||
|
Tooltip,
|
||||||
|
TooltipContent,
|
||||||
|
TooltipTrigger,
|
||||||
|
} from "@/components/ui/tooltip";
|
||||||
import { Search, Heart } from "lucide-react";
|
import { Search, Heart } from "lucide-react";
|
||||||
import { getProfileUrl } from "@/lib/media-utils";
|
import { getProfileUrl, formatDate, calculateAge } from "@/lib/media-utils";
|
||||||
|
|
||||||
type PeopleFilter = "all" | "favorite";
|
type PeopleFilter = "all" | "favorite";
|
||||||
|
|
||||||
@@ -207,6 +212,18 @@ export function PeoplePage() {
|
|||||||
<p className="text-sm font-medium line-clamp-2">
|
<p className="text-sm font-medium line-clamp-2">
|
||||||
{person.name}
|
{person.name}
|
||||||
</p>
|
</p>
|
||||||
|
{person.birthday && (
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger render={<span />}>
|
||||||
|
<span className="text-xs text-muted-foreground">
|
||||||
|
Born: {formatDate(person.birthday)}
|
||||||
|
</span>
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent>
|
||||||
|
Age: {calculateAge(person.birthday, person.deathday)}
|
||||||
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -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 { useState, useEffect } from "react";
|
||||||
import {
|
import {
|
||||||
usePerson,
|
usePerson,
|
||||||
@@ -13,8 +13,14 @@ import { Skeleton } from "@/components/ui/skeleton";
|
|||||||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
|
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
|
||||||
import { Separator } from "@/components/ui/separator";
|
import { Separator } from "@/components/ui/separator";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
import {
|
||||||
|
Tooltip,
|
||||||
|
TooltipContent,
|
||||||
|
TooltipTrigger,
|
||||||
|
} from "@/components/ui/tooltip";
|
||||||
import { EntryCard } from "@/components/entries/EntryCard";
|
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 {
|
import {
|
||||||
ChevronLeft,
|
ChevronLeft,
|
||||||
ChevronRight,
|
ChevronRight,
|
||||||
@@ -24,58 +30,131 @@ import {
|
|||||||
ExternalLink,
|
ExternalLink,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import type { TmdbEntry } from "@/types";
|
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";
|
/** 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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() {
|
export function PersonDetailsPage() {
|
||||||
const { id, tmdbId } = useParams<{ id?: string; tmdbId?: string }>();
|
const { id, tmdbId } = useParams<{ id?: string; tmdbId?: string }>();
|
||||||
const location = useLocation();
|
|
||||||
const isTmdbMode = location.pathname.startsWith("/people/tmdb/");
|
|
||||||
|
|
||||||
if (isTmdbMode && tmdbId) {
|
|
||||||
return <TmdbPersonView tmdbId={parseInt(tmdbId, 10)} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
return <LocalPersonView personId={parseInt(id!, 10)} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ─── Local DB person ─── */
|
|
||||||
|
|
||||||
function LocalPersonView({ personId }: { personId: number }) {
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { data: person, isLoading, isError } = usePerson(personId);
|
const localId = id ? parseInt(id, 10) : 0;
|
||||||
const { data: tmdbFilmography, isLoading: tmdbLoading } =
|
const isLocal = !!localId;
|
||||||
usePersonTmdbFilmography(personId);
|
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 updatePerson = useUpdatePerson();
|
||||||
|
const fetchPerson = useFetchPersonByTmdbId();
|
||||||
useLibrary();
|
useLibrary();
|
||||||
const libraryMap = useLibraryStore((s) => s.entries);
|
const libraryMap = useLibraryStore((s) => s.entries);
|
||||||
const libraryLoaded = useLibraryStore((s) => s.isLoaded);
|
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) {
|
if (isError) {
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col items-center justify-center gap-3 py-20">
|
<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-lg font-semibold">Person not found</p>
|
||||||
<p className="text-sm text-muted-foreground">
|
<p className="text-sm text-muted-foreground">
|
||||||
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."}
|
||||||
</p>
|
</p>
|
||||||
<Button variant="outline" onClick={() => navigate("/people")}>
|
<Button
|
||||||
Back to People
|
variant="outline"
|
||||||
|
onClick={() => (isLocal ? navigate("/people") : navigate(-1))}
|
||||||
|
>
|
||||||
|
{isLocal ? "Back to People" : "Go back"}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isLoading || !person) {
|
let person: PersonProfile | null = null;
|
||||||
|
let filmography: TmdbFilmographyResponse | undefined;
|
||||||
|
let filmographyLoading = false;
|
||||||
|
|
||||||
|
if (isLocal && localPerson.data) {
|
||||||
|
const p = localPerson.data;
|
||||||
|
person = {
|
||||||
|
name: p.name,
|
||||||
|
biography: p.biography ?? null,
|
||||||
|
birthday: p.birthday ?? null,
|
||||||
|
deathday: p.deathday ?? null,
|
||||||
|
place_of_birth: p.place_of_birth ?? null,
|
||||||
|
profile_path: p.profile_path ?? null,
|
||||||
|
known_for_department: p.known_for_department ?? null,
|
||||||
|
tmdb_id: p.tmdb_id ?? null,
|
||||||
|
favorite: !!p.favorite,
|
||||||
|
};
|
||||||
|
filmography = localFilmography.data;
|
||||||
|
filmographyLoading = localFilmography.isLoading;
|
||||||
|
} else if (!isLocal && tmdbPreview.data && !existingLocalId) {
|
||||||
|
const p = tmdbPreview.data;
|
||||||
|
person = { ...p, favorite: false };
|
||||||
|
filmography = p.filmography;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Still loading, or about to redirect to the local page.
|
||||||
|
if (!person) {
|
||||||
return <PersonSkeleton />;
|
return <PersonSkeleton />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isFavorite = person.favorite;
|
||||||
|
|
||||||
|
const toggleFavorite = () => {
|
||||||
|
updatePerson.mutate({ id: localId, data: { favorite: !isFavorite } });
|
||||||
|
};
|
||||||
|
|
||||||
|
const addToLibrary = () => {
|
||||||
|
fetchPerson.mutate(tmdbIdNum, {
|
||||||
|
onSuccess: (added) => {
|
||||||
|
navigate(`/people/${added.id}`, { replace: true });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-8 animate-page-enter">
|
<div className="space-y-8 animate-page-enter">
|
||||||
<div className="flex flex-col items-center gap-4 sm:flex-row sm:items-start sm:gap-8">
|
<div className="flex flex-col items-center gap-4 sm:flex-row sm:items-start sm:gap-8">
|
||||||
<Avatar className="h-32 w-32 shrink-0 sm:h-48 sm:w-48">
|
<Avatar className="h-32 w-32 shrink-0 sm:h-48 sm:w-48">
|
||||||
<AvatarImage
|
<AvatarImage
|
||||||
src={getProfileUrl(person.profile_path)}
|
src={
|
||||||
|
person.profile_path
|
||||||
|
? getTmdbImageUrl(person.profile_path, "w300")
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
alt={person.name}
|
alt={person.name}
|
||||||
/>
|
/>
|
||||||
<AvatarFallback className="text-2xl sm:text-3xl">
|
<AvatarFallback className="text-2xl sm:text-3xl">
|
||||||
@@ -88,22 +167,33 @@ function LocalPersonView({ personId }: { personId: number }) {
|
|||||||
<div className="space-y-2 text-center sm:text-left sm:space-y-3">
|
<div className="space-y-2 text-center sm:text-left sm:space-y-3">
|
||||||
<div className="flex items-center gap-2 justify-center sm:justify-start">
|
<div className="flex items-center gap-2 justify-center sm:justify-start">
|
||||||
<h1 className="text-2xl font-bold sm:text-3xl">{person.name}</h1>
|
<h1 className="text-2xl font-bold sm:text-3xl">{person.name}</h1>
|
||||||
|
{isLocal ? (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="icon"
|
size="icon"
|
||||||
className="h-8 w-8 shrink-0"
|
className="h-8 w-8 shrink-0"
|
||||||
onClick={() =>
|
onClick={toggleFavorite}
|
||||||
updatePerson.mutate({
|
|
||||||
id: person.id,
|
|
||||||
data: { favorite: !person.favorite },
|
|
||||||
})
|
|
||||||
}
|
|
||||||
disabled={updatePerson.isPending}
|
disabled={updatePerson.isPending}
|
||||||
>
|
>
|
||||||
<Heart
|
<Heart
|
||||||
className={`h-5 w-5 ${person.favorite ? "fill-red-500 text-red-500" : "text-muted-foreground"}`}
|
className={`h-5 w-5 ${isFavorite ? "fill-red-500 text-red-500" : "text-muted-foreground"}`}
|
||||||
/>
|
/>
|
||||||
</Button>
|
</Button>
|
||||||
|
) : (
|
||||||
|
<Button
|
||||||
|
onClick={addToLibrary}
|
||||||
|
disabled={fetchPerson.isPending}
|
||||||
|
size="sm"
|
||||||
|
className="ml-1"
|
||||||
|
>
|
||||||
|
{fetchPerson.isPending ? (
|
||||||
|
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
||||||
|
) : (
|
||||||
|
<Plus className="mr-2 h-4 w-4" />
|
||||||
|
)}
|
||||||
|
{fetchPerson.isPending ? "Adding..." : "Add to Library"}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<PersonMeta
|
<PersonMeta
|
||||||
known_for_department={person.known_for_department}
|
known_for_department={person.known_for_department}
|
||||||
@@ -123,117 +213,12 @@ function LocalPersonView({ personId }: { personId: number }) {
|
|||||||
<Separator />
|
<Separator />
|
||||||
|
|
||||||
<FilmographySection
|
<FilmographySection
|
||||||
|
// Reset pagination when moving between people on the same route
|
||||||
|
key={isLocal ? `local-${localId}` : `tmdb-${tmdbIdNum}`}
|
||||||
libraryMap={libraryMap}
|
libraryMap={libraryMap}
|
||||||
libraryLoaded={libraryLoaded}
|
libraryLoaded={libraryLoaded}
|
||||||
tmdbFilmography={tmdbFilmography}
|
tmdbFilmography={filmography}
|
||||||
tmdbLoading={tmdbLoading}
|
tmdbLoading={filmographyLoading}
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ─── TMDB person (not in library) ─── */
|
|
||||||
|
|
||||||
function TmdbPersonView({ tmdbId }: { tmdbId: number }) {
|
|
||||||
const navigate = useNavigate();
|
|
||||||
const { data: preview, isLoading, isError } = useTmdbPersonPreview(tmdbId);
|
|
||||||
const fetchPerson = useFetchPersonByTmdbId();
|
|
||||||
useLibrary();
|
|
||||||
const libraryMap = useLibraryStore((s) => s.entries);
|
|
||||||
const libraryLoaded = useLibraryStore((s) => s.isLoaded);
|
|
||||||
|
|
||||||
// If person already exists in local DB, redirect to their local page
|
|
||||||
useEffect(() => {
|
|
||||||
if (preview?.local_id) {
|
|
||||||
navigate(`/people/${preview.local_id}`, { replace: true });
|
|
||||||
}
|
|
||||||
}, [preview?.local_id, navigate]);
|
|
||||||
|
|
||||||
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">
|
|
||||||
Could not load person data from TMDB.
|
|
||||||
</p>
|
|
||||||
<Button variant="outline" onClick={() => navigate(-1)}>
|
|
||||||
Go back
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isLoading || !preview) {
|
|
||||||
return <PersonSkeleton />;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Redirecting to local page, show skeleton while navigating
|
|
||||||
if (preview.local_id) {
|
|
||||||
return <PersonSkeleton />;
|
|
||||||
}
|
|
||||||
|
|
||||||
const profileUrl = preview.profile_path
|
|
||||||
? `${TMDB_IMG}/w300${preview.profile_path}`
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
const handleAddToLibrary = () => {
|
|
||||||
fetchPerson.mutate(tmdbId, {
|
|
||||||
onSuccess: (person) => {
|
|
||||||
navigate(`/people/${person.id}`, { replace: true });
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="space-y-8 animate-page-enter">
|
|
||||||
<div className="flex flex-col items-center gap-4 sm:flex-row sm:items-start sm:gap-8">
|
|
||||||
<Avatar className="h-32 w-32 shrink-0 sm:h-48 sm:w-48">
|
|
||||||
<AvatarImage src={profileUrl} alt={preview.name} />
|
|
||||||
<AvatarFallback className="text-2xl sm:text-3xl">
|
|
||||||
{preview.name
|
|
||||||
.split(" ")
|
|
||||||
.map((n: string) => n[0])
|
|
||||||
.join("")}
|
|
||||||
</AvatarFallback>
|
|
||||||
</Avatar>
|
|
||||||
<div className="space-y-2 text-center sm:text-left sm:space-y-3">
|
|
||||||
<div className="flex items-center gap-3 justify-center sm:justify-start">
|
|
||||||
<h1 className="text-2xl font-bold sm:text-3xl">{preview.name}</h1>
|
|
||||||
<Button
|
|
||||||
onClick={handleAddToLibrary}
|
|
||||||
disabled={fetchPerson.isPending}
|
|
||||||
size="sm"
|
|
||||||
>
|
|
||||||
{fetchPerson.isPending ? (
|
|
||||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
|
||||||
) : (
|
|
||||||
<Plus className="mr-2 h-4 w-4" />
|
|
||||||
)}
|
|
||||||
{fetchPerson.isPending ? "Adding..." : "Add to Library"}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
<PersonMeta
|
|
||||||
known_for_department={preview.known_for_department}
|
|
||||||
birthday={preview.birthday}
|
|
||||||
deathday={preview.deathday}
|
|
||||||
place_of_birth={preview.place_of_birth}
|
|
||||||
tmdb_id={preview.tmdb_id}
|
|
||||||
/>
|
|
||||||
{preview.biography && (
|
|
||||||
<p className="text-sm text-muted-foreground leading-relaxed max-w-2xl line-clamp-6">
|
|
||||||
{preview.biography}
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Separator />
|
|
||||||
|
|
||||||
<FilmographySection
|
|
||||||
libraryMap={libraryMap}
|
|
||||||
libraryLoaded={libraryLoaded}
|
|
||||||
tmdbFilmography={preview.filmography}
|
|
||||||
tmdbLoading={false}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -260,7 +245,14 @@ function PersonMeta({
|
|||||||
{birthday && (
|
{birthday && (
|
||||||
<>
|
<>
|
||||||
<span>•</span>
|
<span>•</span>
|
||||||
<span>Born: {formatDate(birthday)}</span>
|
<Tooltip>
|
||||||
|
<TooltipTrigger render={<span className="cursor-default" />}>
|
||||||
|
Born: {formatDate(birthday)}
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent>
|
||||||
|
Age: {calculateAge(birthday, deathday)}
|
||||||
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{deathday && (
|
{deathday && (
|
||||||
|
|||||||
@@ -1,364 +0,0 @@
|
|||||||
import { useState } from "react";
|
|
||||||
import { useParams, useNavigate } from "react-router-dom";
|
|
||||||
import {
|
|
||||||
useTmdbPersonPreview,
|
|
||||||
useFetchPersonByTmdbId,
|
|
||||||
} 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 { Button } from "@/components/ui/button";
|
|
||||||
import { EntryCard } from "@/components/entries/EntryCard";
|
|
||||||
import { getProfileUrl, formatDate } from "@/lib/media-utils";
|
|
||||||
import { Plus, Loader2, ChevronLeft, ChevronRight } from "lucide-react";
|
|
||||||
import type { TmdbEntry } from "@/types";
|
|
||||||
import type { TmdbFilmographyItem } from "@/api/people";
|
|
||||||
|
|
||||||
const TMDB_IMG = "https://image.tmdb.org/t/p";
|
|
||||||
|
|
||||||
export function PersonTmdbRedirectPage() {
|
|
||||||
const { tmdbId } = useParams<{ tmdbId: string }>();
|
|
||||||
const navigate = useNavigate();
|
|
||||||
const tmdbIdNum = parseInt(tmdbId!, 10);
|
|
||||||
|
|
||||||
const { data: preview, isLoading, isError } = useTmdbPersonPreview(tmdbIdNum);
|
|
||||||
const fetchPerson = useFetchPersonByTmdbId();
|
|
||||||
useLibrary();
|
|
||||||
const libraryMap = useLibraryStore((s) => s.entries);
|
|
||||||
const libraryLoaded = useLibraryStore((s) => s.isLoaded);
|
|
||||||
|
|
||||||
if (isLoading || !preview) {
|
|
||||||
return (
|
|
||||||
<div className="space-y-6">
|
|
||||||
<div className="flex flex-col items-center gap-4 sm:flex-row sm:items-start sm:gap-6">
|
|
||||||
<Skeleton className="h-32 w-32 rounded-full sm:h-48 sm:w-48" />
|
|
||||||
<div className="flex-1 space-y-3 w-full">
|
|
||||||
<Skeleton className="h-8 w-48 mx-auto sm:mx-0" />
|
|
||||||
<Skeleton className="h-4 w-32 mx-auto sm:mx-0" />
|
|
||||||
<Skeleton className="h-20 w-full" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
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">
|
|
||||||
Could not load person data from TMDB.
|
|
||||||
</p>
|
|
||||||
<Button variant="outline" onClick={() => navigate(-1)}>
|
|
||||||
Go back
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const profileUrl = preview.profile_path
|
|
||||||
? `${TMDB_IMG}/w300${preview.profile_path}`
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
const handleAddToLibrary = () => {
|
|
||||||
fetchPerson.mutate(tmdbIdNum, {
|
|
||||||
onSuccess: (person) => {
|
|
||||||
navigate(`/people/${person.id}`, { replace: true });
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="space-y-8 animate-page-enter">
|
|
||||||
<div className="flex flex-col items-center gap-4 sm:flex-row sm:items-start sm:gap-8">
|
|
||||||
<Avatar className="h-32 w-32 shrink-0 sm:h-48 sm:w-48">
|
|
||||||
<AvatarImage src={profileUrl} alt={preview.name} />
|
|
||||||
<AvatarFallback className="text-2xl sm:text-3xl">
|
|
||||||
{preview.name
|
|
||||||
.split(" ")
|
|
||||||
.map((n: string) => n[0])
|
|
||||||
.join("")}
|
|
||||||
</AvatarFallback>
|
|
||||||
</Avatar>
|
|
||||||
<div className="space-y-2 text-center sm:text-left sm:space-y-3">
|
|
||||||
<div className="flex items-center gap-3 justify-center sm:justify-start">
|
|
||||||
<h1 className="text-2xl font-bold sm:text-3xl">{preview.name}</h1>
|
|
||||||
<Button
|
|
||||||
onClick={handleAddToLibrary}
|
|
||||||
disabled={fetchPerson.isPending}
|
|
||||||
size="sm"
|
|
||||||
>
|
|
||||||
{fetchPerson.isPending ? (
|
|
||||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
|
||||||
) : (
|
|
||||||
<Plus className="mr-2 h-4 w-4" />
|
|
||||||
)}
|
|
||||||
{fetchPerson.isPending ? "Adding..." : "Add to Library"}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
<div className="flex flex-wrap items-center justify-center gap-2 text-sm text-muted-foreground sm:justify-start sm:gap-3">
|
|
||||||
{preview.known_for_department && (
|
|
||||||
<span>{preview.known_for_department}</span>
|
|
||||||
)}
|
|
||||||
{preview.birthday && (
|
|
||||||
<>
|
|
||||||
<span>•</span>
|
|
||||||
<span>Born: {formatDate(preview.birthday)}</span>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{preview.deathday && (
|
|
||||||
<>
|
|
||||||
<span>•</span>
|
|
||||||
<span>Died: {formatDate(preview.deathday)}</span>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{preview.place_of_birth && (
|
|
||||||
<>
|
|
||||||
<span>•</span>
|
|
||||||
<span>{preview.place_of_birth}</span>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
{preview.biography && (
|
|
||||||
<p className="text-sm text-muted-foreground leading-relaxed max-w-2xl line-clamp-6">
|
|
||||||
{preview.biography}
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Separator />
|
|
||||||
|
|
||||||
<TmdbFilmographySection
|
|
||||||
filmography={preview.filmography}
|
|
||||||
libraryMap={libraryMap}
|
|
||||||
libraryLoaded={libraryLoaded}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
interface TmdbFilmographySectionProps {
|
|
||||||
filmography: { cast: TmdbFilmographyItem[]; crew: TmdbFilmographyItem[] };
|
|
||||||
libraryMap: Map<number, import("@/types").Entry>;
|
|
||||||
libraryLoaded: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
function TmdbFilmographySection({
|
|
||||||
filmography,
|
|
||||||
libraryMap,
|
|
||||||
libraryLoaded,
|
|
||||||
}: TmdbFilmographySectionProps) {
|
|
||||||
const [libraryPage, setLibraryPage] = useState(0);
|
|
||||||
const [otherPage, setOtherPage] = useState(0);
|
|
||||||
const PAGE_SIZE = 6;
|
|
||||||
const GRID =
|
|
||||||
"grid grid-cols-2 gap-3 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6";
|
|
||||||
|
|
||||||
if (!libraryLoaded) {
|
|
||||||
return (
|
|
||||||
<div className="space-y-4">
|
|
||||||
<h2 className="text-xl font-semibold">Filmography</h2>
|
|
||||||
<div className={GRID}>
|
|
||||||
{Array.from({ length: 6 }).map((_, i) => (
|
|
||||||
<Skeleton key={i} className="aspect-2/3 rounded-lg" />
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const allCredits = [
|
|
||||||
...(filmography.cast ?? []),
|
|
||||||
...(filmography.crew?.filter(
|
|
||||||
(c) => c.job === "Director" || c.department === "Directing",
|
|
||||||
) ?? []),
|
|
||||||
];
|
|
||||||
const seenIds = new Set<number>();
|
|
||||||
const deduped = allCredits.filter((c) => {
|
|
||||||
if (seenIds.has(c.id)) return false;
|
|
||||||
seenIds.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 sorted = [...deduped].sort(
|
|
||||||
(a, b) => (b.popularity ?? 0) - (a.popularity ?? 0),
|
|
||||||
);
|
|
||||||
const libraryCredits = sorted.filter((c) => tmdbIdToLibraryEntry.has(c.id));
|
|
||||||
|
|
||||||
const isSelfRole = (character?: string) => {
|
|
||||||
if (!character) return false;
|
|
||||||
const lower = character.toLowerCase().trim();
|
|
||||||
return (
|
|
||||||
lower === "self" ||
|
|
||||||
lower.startsWith("self -") ||
|
|
||||||
lower.startsWith("self (") ||
|
|
||||||
lower === "themselves" ||
|
|
||||||
lower === "himself" ||
|
|
||||||
lower === "herself"
|
|
||||||
);
|
|
||||||
};
|
|
||||||
const otherCredits = sorted
|
|
||||||
.filter((c) => !tmdbIdToLibraryEntry.has(c.id))
|
|
||||||
.sort((a, b) => {
|
|
||||||
const aSelf = isSelfRole(a.character) ? 1 : 0;
|
|
||||||
const bSelf = isSelfRole(b.character) ? 1 : 0;
|
|
||||||
if (aSelf !== bSelf) return aSelf - bSelf;
|
|
||||||
const dateA = new Date(
|
|
||||||
a.release_date || a.first_air_date || "1900",
|
|
||||||
).getTime();
|
|
||||||
const dateB = new Date(
|
|
||||||
b.release_date || b.first_air_date || "1900",
|
|
||||||
).getTime();
|
|
||||||
return dateB - dateA;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (sorted.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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const librarySlice = libraryCredits.slice(
|
|
||||||
libraryPage * PAGE_SIZE,
|
|
||||||
(libraryPage + 1) * PAGE_SIZE,
|
|
||||||
);
|
|
||||||
const otherSlice = otherCredits.slice(
|
|
||||||
otherPage * PAGE_SIZE,
|
|
||||||
(otherPage + 1) * PAGE_SIZE,
|
|
||||||
);
|
|
||||||
const libraryTotalPages = Math.ceil(libraryCredits.length / PAGE_SIZE);
|
|
||||||
const otherTotalPages = Math.ceil(otherCredits.length / PAGE_SIZE);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="space-y-8">
|
|
||||||
<h2 className="text-xl font-semibold">Filmography</h2>
|
|
||||||
|
|
||||||
{libraryCredits.length > 0 && (
|
|
||||||
<div className="space-y-3">
|
|
||||||
<div className="flex items-center justify-between">
|
|
||||||
<h3 className="text-sm font-medium text-muted-foreground uppercase tracking-wide">
|
|
||||||
In Your Library ({libraryCredits.length})
|
|
||||||
</h3>
|
|
||||||
{libraryTotalPages > 1 && (
|
|
||||||
<div className="flex items-center gap-1">
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="h-7 w-7"
|
|
||||||
disabled={libraryPage === 0}
|
|
||||||
onClick={() => setLibraryPage((p) => p - 1)}
|
|
||||||
>
|
|
||||||
<ChevronLeft className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
<span className="text-xs text-muted-foreground tabular-nums">
|
|
||||||
{libraryPage + 1}/{libraryTotalPages}
|
|
||||||
</span>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="h-7 w-7"
|
|
||||||
disabled={libraryPage === libraryTotalPages - 1}
|
|
||||||
onClick={() => setLibraryPage((p) => p + 1)}
|
|
||||||
>
|
|
||||||
<ChevronRight className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div className={GRID}>
|
|
||||||
{librarySlice.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">
|
|
||||||
<div className="flex items-center justify-between">
|
|
||||||
<h3 className="text-sm font-medium text-muted-foreground uppercase tracking-wide">
|
|
||||||
Not in Library ({otherCredits.length})
|
|
||||||
</h3>
|
|
||||||
{otherTotalPages > 1 && (
|
|
||||||
<div className="flex items-center gap-1">
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="h-7 w-7"
|
|
||||||
disabled={otherPage === 0}
|
|
||||||
onClick={() => setOtherPage((p) => p - 1)}
|
|
||||||
>
|
|
||||||
<ChevronLeft className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
<span className="text-xs text-muted-foreground tabular-nums">
|
|
||||||
{otherPage + 1}/{otherTotalPages}
|
|
||||||
</span>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="h-7 w-7"
|
|
||||||
disabled={otherPage === otherTotalPages - 1}
|
|
||||||
onClick={() => setOtherPage((p) => p + 1)}
|
|
||||||
>
|
|
||||||
<ChevronRight className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div className={GRID}>
|
|
||||||
{otherSlice.map((credit) => {
|
|
||||||
const tmdbEntry: TmdbEntry = {
|
|
||||||
id: credit.id,
|
|
||||||
title: credit.title,
|
|
||||||
name: credit.name,
|
|
||||||
poster_path: credit.poster_path,
|
|
||||||
backdrop_path: null,
|
|
||||||
release_date: credit.release_date,
|
|
||||||
first_air_date: credit.first_air_date,
|
|
||||||
media_type: credit.media_type,
|
|
||||||
overview: "",
|
|
||||||
vote_average: 0,
|
|
||||||
vote_count: 0,
|
|
||||||
genre_ids: [],
|
|
||||||
popularity: credit.popularity ?? 0,
|
|
||||||
};
|
|
||||||
return (
|
|
||||||
<div key={credit.id} className="space-y-1">
|
|
||||||
<EntryCard tmdbEntry={tmdbEntry} />
|
|
||||||
{credit.character && (
|
|
||||||
<p className="text-xs text-muted-foreground text-center line-clamp-1 px-1">
|
|
||||||
{credit.character}
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user