diff --git a/react_frontend/src/components/entries/CastList.tsx b/react_frontend/src/components/entries/CastList.tsx index dbb669c..26086b5 100644 --- a/react_frontend/src/components/entries/CastList.tsx +++ b/react_frontend/src/components/entries/CastList.tsx @@ -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 (
{credit.character}
- {isTvSeries && credit.episode_count != null && credit.episode_count > 0 && ( -- {credit.episode_count} ep. -
- )} + {isTvSeries && + credit.episode_count != null && + credit.episode_count > 0 && ( ++ {credit.episode_count} ep. +
+ )}{title}
diff --git a/react_frontend/src/components/home/UpcomingCard.tsx b/react_frontend/src/components/home/UpcomingCard.tsx index 642b400..8653fb5 100644 --- a/react_frontend/src/components/home/UpcomingCard.tsx +++ b/react_frontend/src/components/home/UpcomingCard.tsx @@ -1,11 +1,12 @@ -import { Link } from 'react-router-dom'; -import type { TmdbEntry } from '@/types'; +import { Link } from "react-router-dom"; +import type { TmdbEntry } from "@/types"; +import { useTmdbEntryLink } from "@/hooks/useTmdbEntryLink"; function formatRelativeTime(dateStr: string): string { const now = new Date(); const release = new Date(dateStr); const diffMs = release.getTime() - now.getTime(); - if (diffMs <= 0) return 'Out now'; + if (diffMs <= 0) return "Out now"; const totalMinutes = Math.floor(diffMs / 60000); const totalHours = Math.floor(totalMinutes / 60); const totalDays = Math.floor(totalHours / 24); @@ -13,10 +14,11 @@ function formatRelativeTime(dateStr: string): string { const remDays = totalDays % 30; if (months > 0 && remDays > 0) return `in ${months}m ${remDays}d`; if (months > 0) return `in ${months}m`; - if (totalDays > 0) return `in ${totalDays} day${totalDays !== 1 ? 's' : ''}`; - if (totalHours > 0) return `in ${totalHours} hour${totalHours !== 1 ? 's' : ''}`; + if (totalDays > 0) return `in ${totalDays} day${totalDays !== 1 ? "s" : ""}`; + if (totalHours > 0) + return `in ${totalHours} hour${totalHours !== 1 ? "s" : ""}`; if (totalMinutes > 0) return `in ${totalMinutes} min`; - return 'Very soon'; + return "Very soon"; } interface UpcomingCardProps { @@ -24,12 +26,11 @@ interface UpcomingCardProps { } export function UpcomingCard({ entry }: UpcomingCardProps) { - const title = entry.title || entry.name || 'Untitled'; + const title = entry.title || entry.name || "Untitled"; const poster = entry.poster_path ? `https://image.tmdb.org/t/p/w185${entry.poster_path}` : null; - const isTv = entry.media_type === 'tv' || !!entry.name; - const linkTo = `/entry/tmdb/${isTv ? 'tv' : 'movie'}/${entry.id}`; + const { linkTo } = useTmdbEntryLink(entry); const releaseDate = entry.release_date || entry.first_air_date; const relativeTime = releaseDate ? formatRelativeTime(releaseDate) : null; @@ -37,9 +38,9 @@ export function UpcomingCard({ entry }: UpcomingCardProps) { -- {new Date(releaseDate).toLocaleDateString('en-US', { - month: 'short', - day: 'numeric', - year: 'numeric', + {new Date(releaseDate).toLocaleDateString("en-US", { + month: "short", + day: "numeric", + year: "numeric", })}
+ No credits found. +
+ ) : ( + <> ++ {credit.people?.name} +
+ {roleLabel && ( ++ {roleLabel} +
+ )} + {isTv && credit.episode_count != null && credit.episode_count > 0 && ( ++ {credit.episode_count}{" "} + {credit.episode_count === 1 ? "episode" : "episodes"} +
+ )} +Could not load entry from TMDB.
- +