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; /** Section heading (default: "Cast") */ title?: string; } export function CastList({ credits, entryId, isTvSeries, maxItems, allCastHref, title = "Cast", }: 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 (

{title}

{allCastLink && ( All Cast & Crew )}
{castCredits.map((credit) => ( ))}
); } function CastCard({ credit, isTvSeries, }: { credit: Credit; isTvSeries?: boolean; }) { const profileUrl = credit.people?.profile_path ? getProfileUrl(credit.people.profile_path) : undefined; // For local DB credits, link to /people/:id. For TMDB preview credits (no entry_id), link via tmdb_id. const personLink = credit.entry_id ? `/people/${credit.people_id}` : `/people/tmdb/${credit.people?.tmdb_id ?? credit.people_id}`; return ( {credit.people?.name ?.split(" ") .map((n) => n[0]) .join("")}

{credit.people?.name}

{credit.character}

{isTvSeries && credit.episode_count != null && credit.episode_count > 0 && (

{credit.episode_count} ep.

)}
); }