Fix home page navigation and add TMDB cast page

Home page cards now check library store and link directly to EntryDetailsPage
when the entry is already added. Created useTmdbEntryLink hook for shared
library-check logic. Added TmdbCastsPage with filter/search/sort for
TMDB preview cast & crew, and limited credits to 12 on TmdbPreviewPage.
This commit is contained in:
X4Lo committed 2026-06-18 13:37:39 +01:00
1 parent 6c2fd3837b
commit 8671184dc5
9 files changed
+540 -136

No files matched your search

@@ -1,28 +1,45 @@
import { Link } from 'react-router-dom';
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
import { ScrollArea, ScrollBar } from '@/components/ui/scroll-area';
import { getProfileUrl } from '@/lib/media-utils';
import { ChevronRight } from 'lucide-react';
import type { Credit } from '@/types';
import { Link } from "react-router-dom";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
import { getProfileUrl } from "@/lib/media-utils";
import { ChevronRight } from "lucide-react";
import type { Credit } from "@/types";
interface CastListProps {
credits: Credit[];
entryId?: number;
isTvSeries?: boolean;
/** Limit visible cast cards (default: show all) */
maxItems?: number;
/** Override link for "All Cast & Crew" — if unset, uses /entry/:entryId/cast */
allCastHref?: string;
}
export function CastList({ credits, entryId, isTvSeries }: CastListProps) {
const castCredits = credits.filter((c) => c.cast_type === 'cast');
export function CastList({
credits,
entryId,
isTvSeries,
maxItems,
allCastHref,
}: CastListProps) {
let castCredits = credits.filter((c) => c.cast_type === "cast");
const hasMore = maxItems != null && castCredits.length > maxItems;
if (hasMore) {
castCredits = castCredits.slice(0, maxItems);
}
if (castCredits.length === 0) return null;
const allCastLink =
allCastHref || (entryId != null ? `/entry/${entryId}/cast` : null);
return (
<div className="space-y-3">
<div className="flex items-center justify-between">
<h3 className="text-lg font-semibold">Cast</h3>
{entryId != null && (
{allCastLink && (
<Link
to={`/entry/${entryId}/cast`}
to={allCastLink}
className="inline-flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors"
>
All Cast &amp; Crew
@@ -42,7 +59,13 @@ export function CastList({ credits, entryId, isTvSeries }: CastListProps) {
);
}
function CastCard({ credit, isTvSeries }: { credit: Credit; isTvSeries?: boolean }) {
function CastCard({
credit,
isTvSeries,
}: {
credit: Credit;
isTvSeries?: boolean;
}) {
const profileUrl = credit.people?.profile_path
? getProfileUrl(credit.people.profile_path)
: undefined;
@@ -61,9 +84,9 @@ function CastCard({ credit, isTvSeries }: { credit: Credit; isTvSeries?: boolean
<AvatarImage src={profileUrl} alt={credit.people?.name} />
<AvatarFallback className="text-xs">
{credit.people?.name
?.split(' ')
?.split(" ")
.map((n) => n[0])
.join('')}
.join("")}
</AvatarFallback>
</Avatar>
<div>
@@ -73,11 +96,13 @@ function CastCard({ credit, isTvSeries }: { credit: Credit; isTvSeries?: boolean
<p className="text-[10px] text-muted-foreground leading-tight line-clamp-1">
{credit.character}
</p>
{isTvSeries && credit.episode_count != null && credit.episode_count > 0 && (
<p className="text-[10px] text-muted-foreground/70 leading-tight">
{credit.episode_count} ep.
</p>
)}
{isTvSeries &&
credit.episode_count != null &&
credit.episode_count > 0 && (
<p className="text-[10px] text-muted-foreground/70 leading-tight">
{credit.episode_count} ep.
</p>
)}
</div>
</Link>
);