feat(frontend): unify person routing, cast page, and centralize ratings

- Add EntryCastsPage at /entry/:id/cast with sort/filter and breadcrumb nav
- Show episode count under character names for TV series in CastList
- Add "All Cast & Crew →" link to CastList section header
- Extract reusable StarRating component with half-star support and 3 sizes
- Replace all rating UIs (EntrySettingsDialog, CollectionEditDialog, RatingDialog)
- Document StarRating component as the single rating standard in Components.md

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Mohammed AbadandCopilot committed 2026-04-27 13:45:48 +01:00
1 parent b3002a329d
commit e460290b9b
11 files changed
+392 -146

No files matched your search

+19 -1
View File
@@ -78,6 +78,24 @@ See [[Statistics]] for data details.
Base components from shadcn/ui in `components/ui/`: Base components from shadcn/ui in `components/ui/`:
`badge`, `avatar`, `button`, `calendar`, `card`, `checkbox`, `dialog`, `dropdown-menu`, `input`, `label`, `popover`, `progress`, `scroll-area`, `select`, `separator`, `sheet`, `skeleton`, `sonner`, `switch`, `tabs`, `textarea`, `tooltip` `badge`, `avatar`, `button`, `calendar`, `card`, `checkbox`, `dialog`, `dropdown-menu`, `input`, `label`, `popover`, `progress`, `scroll-area`, `select`, `separator`, `sheet`, `skeleton`, `sonner`, `star-rating`, `switch`, `tabs`, `textarea`, `tooltip`
### StarRating
> [!important] Centralized Rating Component
> All user rating inputs across the application MUST use `StarRating` from `components/ui/star-rating.tsx`.
| Prop | Type | Default | Description |
|---|---|---|---|
| `value` | `number` | — | Current rating value (0–10, supports halves like 7.5) |
| `onChange` | `(rating: number) => void` | — | Callback when user clicks a star. Clicking same value resets to 0 |
| `max` | `number` | `10` | Number of stars |
| `size` | `'sm' \| 'md' \| 'lg'` | `'lg'` | Star icon size (`h-4`, `h-6`, `h-8`) |
| `readOnly` | `boolean` | `false` | Disables interaction |
Used in:
- [[Components#Dialogs|RatingDialog]] — Entry rating dialog (size `lg`)
- [[Components#Dialogs|EntrySettingsDialog]] — Inline entry rating (size `sm`)
- [[Components#Dialogs|CollectionEditDialog]] — Collection rating (size `md`)
Theme: **base-nova** style. Theme: **base-nova** style.
+12 -1
View File
@@ -66,9 +66,20 @@ Sections:
- Actions: watchlist, favorite, refresh, settings, rating - Actions: watchlist, favorite, refresh, settings, rating
- Watch history (movies) → [[Watch Tracking]] - Watch history (movies) → [[Watch Tracking]]
- Seasons list (TV) → links to SeasonPage - Seasons list (TV) → links to SeasonPage
- Cast list → links to PersonDetailsPage - Cast list → links to PersonDetailsPage; shows episode count for TV; "All Cast & Crew" link → EntryCastsPage
- Media gallery → [[Media System]] - Media gallery → [[Media System]]
## EntryCastsPage
Full cast & crew grid for an entry. Route: `/entry/:id/cast`. Width: `max-w-4xl`.
- Breadcrumb: `Entry Title / Cast & Crew` (Title links back to EntryDetailsPage)
- Filter: All / Cast / Crew
- Sort: Credit Order, Popularity, Name, Birthday, Gender, Episode Count (TV only)
- Sort direction toggle (asc/desc)
- Shows role/job label and episode count for TV series
- Links to [[Pages#PersonDetailsPage|PersonDetailsPage]]
## SeasonPage ## SeasonPage
Season detail with episode list. Width: `max-w-4xl`. Season detail with episode list. Width: `max-w-4xl`.
@@ -10,7 +10,8 @@ import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input'; import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label'; import { Label } from '@/components/ui/label';
import { Textarea } from '@/components/ui/textarea'; import { Textarea } from '@/components/ui/textarea';
import { ImageIcon, Star } from 'lucide-react'; import { ImageIcon } from 'lucide-react';
import { StarRating } from '@/components/ui/star-rating';
import { useUpdateCollection } from '@/hooks/useCollections'; import { useUpdateCollection } from '@/hooks/useCollections';
import type { Collection } from '@/types'; import type { Collection } from '@/types';
@@ -30,7 +31,6 @@ export function CollectionEditDialog({
const [userRating, setUserRating] = useState( const [userRating, setUserRating] = useState(
collection.user_rating ?? 0 collection.user_rating ?? 0
); );
const [hoveredStar, setHoveredStar] = useState<number | null>(null);
const [posterFile, setPosterFile] = useState<File | null>(null); const [posterFile, setPosterFile] = useState<File | null>(null);
const [backdropFile, setBackdropFile] = useState<File | null>(null); const [backdropFile, setBackdropFile] = useState<File | null>(null);
const [posterPreview, setPosterPreview] = useState<string | null>(null); const [posterPreview, setPosterPreview] = useState<string | null>(null);
@@ -107,30 +107,8 @@ export function CollectionEditDialog({
<div className="space-y-2"> <div className="space-y-2">
<Label>User Rating</Label> <Label>User Rating</Label>
<div className="flex items-center gap-2"> <div className="flex items-center gap-3">
<div className="flex gap-1"> <StarRating value={userRating} onChange={setUserRating} size="md" />
{Array.from({ length: 10 }, (_, i) => i + 1).map((star) => {
const displayRating = hoveredStar ?? userRating;
return (
<button
key={star}
type="button"
className="transition-transform hover:scale-125 focus:outline-none"
onMouseEnter={() => setHoveredStar(star)}
onMouseLeave={() => setHoveredStar(null)}
onClick={() => setUserRating(star === userRating ? 0 : star)}
>
<Star
className={`h-5 w-5 transition-colors ${
star <= displayRating
? 'fill-yellow-400 text-yellow-400'
: 'text-muted-foreground/30'
}`}
/>
</button>
);
})}
</div>
<span className="text-sm text-muted-foreground tabular-nums"> <span className="text-sm text-muted-foreground tabular-nums">
{userRating > 0 ? `${userRating}/10` : '—'} {userRating > 0 ? `${userRating}/10` : '—'}
</span> </span>
@@ -7,10 +7,8 @@ import {
import { Label } from '@/components/ui/label'; import { Label } from '@/components/ui/label';
import { Switch } from '@/components/ui/switch'; import { Switch } from '@/components/ui/switch';
import { Separator } from '@/components/ui/separator'; import { Separator } from '@/components/ui/separator';
import { useUpdateEntry } from '@/hooks/useEntries'; import { useUpdateEntry, useUpdateEntryRatings } from '@/hooks/useEntries';
import { RatingDialog } from '@/components/dialogs/RatingDialog'; import { StarRating } from '@/components/ui/star-rating';
import { useState } from 'react';
import { Star } from 'lucide-react';
import type { Entry } from '@/types'; import type { Entry } from '@/types';
interface EntrySettingsDialogProps { interface EntrySettingsDialogProps {
@@ -25,7 +23,7 @@ export function EntrySettingsDialog({
entry, entry,
}: EntrySettingsDialogProps) { }: EntrySettingsDialogProps) {
const updateEntry = useUpdateEntry(); const updateEntry = useUpdateEntry();
const [showRating, setShowRating] = useState(false); const updateRatings = useUpdateEntryRatings();
const handleToggle = (field: keyof Entry, value: boolean) => { const handleToggle = (field: keyof Entry, value: boolean) => {
updateEntry.mutate({ id: entry.id, data: { [field]: value } }); updateEntry.mutate({ id: entry.id, data: { [field]: value } });
@@ -39,62 +37,47 @@ export function EntrySettingsDialog({
{ field: 'auto_sync' as const, label: 'Auto Sync' }, { field: 'auto_sync' as const, label: 'Auto Sync' },
]; ];
const userRating = entry.entryRatings?.user_rating; const userRating = entry.entryRatings?.user_rating ?? 0;
const handleRatingChange = (rating: number) => {
updateRatings.mutate({
id: entry.id,
ratings: { id: entry.entryRatings?.id, user_rating: rating || null },
});
};
return ( return (
<> <Dialog open={open} onOpenChange={onOpenChange}>
<Dialog open={open} onOpenChange={onOpenChange}> <DialogContent className="sm:max-w-md">
<DialogContent className="sm:max-w-md"> <DialogHeader>
<DialogHeader> <DialogTitle>Entry Settings</DialogTitle>
<DialogTitle>Entry Settings</DialogTitle> <p className="text-sm text-muted-foreground line-clamp-1">{entry.title}</p>
<p className="text-sm text-muted-foreground line-clamp-1">{entry.title}</p> </DialogHeader>
</DialogHeader> <div className="space-y-1 py-2">
<div className="space-y-1 py-2"> {boolSettings.map(({ field, label }) => (
{boolSettings.map(({ field, label }) => ( <div key={field} className="flex items-center justify-between rounded-lg px-1 py-2.5">
<div key={field} className="flex items-center justify-between rounded-lg px-1 py-2.5"> <Label htmlFor={field} className="cursor-pointer">
<Label htmlFor={field} className="cursor-pointer"> {label}
{label} </Label>
</Label> <Switch
<Switch id={field}
id={field} checked={!!entry[field]}
checked={!!entry[field]} onCheckedChange={(checked) => handleToggle(field, checked)}
onCheckedChange={(checked) => handleToggle(field, checked)} />
/> </div>
</div> ))}
))} <Separator className="my-2" />
<Separator className="my-2" /> <div className="space-y-2 rounded-lg px-1 py-2.5">
<div className="flex items-center justify-between rounded-lg px-1 py-2.5"> <Label>Your Rating</Label>
<Label className="cursor-pointer">Your Rating</Label> <div className="flex items-center gap-3">
<button <StarRating value={userRating} onChange={handleRatingChange} size="sm" />
className="flex items-center gap-1.5 text-sm font-medium hover:text-primary transition-colors" <span className="text-sm text-muted-foreground tabular-nums">
onClick={() => setShowRating(true)} {userRating > 0 ? `${userRating}/10` : '—'}
> </span>
{userRating && userRating > 0 ? (
<>
<div className="flex">
{Array.from({ length: 10 }).map((_, i) => (
<Star
key={i}
className={`h-3 w-3 ${i < userRating ? 'fill-yellow-400 text-yellow-400' : 'text-muted-foreground/30'}`}
/>
))}
</div>
<span className="tabular-nums">{userRating}/10</span>
</>
) : (
<span className="text-muted-foreground">Not rated — click to rate</span>
)}
</button>
</div> </div>
</div> </div>
</DialogContent> </div>
</Dialog> </DialogContent>
</Dialog>
<RatingDialog
open={showRating}
onOpenChange={setShowRating}
entry={entry}
/>
</>
); );
} }
@@ -6,7 +6,7 @@ import {
DialogTitle, DialogTitle,
} from '@/components/ui/dialog'; } from '@/components/ui/dialog';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
import { Star } from 'lucide-react'; import { StarRating } from '@/components/ui/star-rating';
import { useUpdateEntryRatings } from '@/hooks/useEntries'; import { useUpdateEntryRatings } from '@/hooks/useEntries';
import type { Entry } from '@/types'; import type { Entry } from '@/types';
@@ -18,27 +18,18 @@ interface RatingDialogProps {
export function RatingDialog({ open, onOpenChange, entry }: RatingDialogProps) { export function RatingDialog({ open, onOpenChange, entry }: RatingDialogProps) {
const currentRating = entry.entryRatings?.user_rating ?? 0; const currentRating = entry.entryRatings?.user_rating ?? 0;
const [hovered, setHovered] = useState<number | null>(null);
const [selected, setSelected] = useState<number>(currentRating); const [selected, setSelected] = useState<number>(currentRating);
const updateRatings = useUpdateEntryRatings(); const updateRatings = useUpdateEntryRatings();
// Sync selected when dialog opens or entry rating changes
useEffect(() => { useEffect(() => {
if (open) { if (open) setSelected(entry.entryRatings?.user_rating ?? 0);
setSelected(entry.entryRatings?.user_rating ?? 0);
}
}, [open, entry.entryRatings?.user_rating]); }, [open, entry.entryRatings?.user_rating]);
const displayRating = hovered ?? selected;
const handleRate = (rating: number) => { const handleRate = (rating: number) => {
setSelected(rating); setSelected(rating);
updateRatings.mutate({ updateRatings.mutate({
id: entry.id, id: entry.id,
ratings: { ratings: { id: entry.entryRatings?.id, user_rating: rating || null },
id: entry.entryRatings?.id,
user_rating: rating || null,
},
}); });
onOpenChange(false); onOpenChange(false);
}; };
@@ -47,10 +38,7 @@ export function RatingDialog({ open, onOpenChange, entry }: RatingDialogProps) {
setSelected(0); setSelected(0);
updateRatings.mutate({ updateRatings.mutate({
id: entry.id, id: entry.id,
ratings: { ratings: { id: entry.entryRatings?.id, user_rating: null },
id: entry.entryRatings?.id,
user_rating: null,
},
}); });
onOpenChange(false); onOpenChange(false);
}; };
@@ -64,47 +52,10 @@ export function RatingDialog({ open, onOpenChange, entry }: RatingDialogProps) {
</DialogHeader> </DialogHeader>
<div className="flex flex-col items-center gap-4 py-2"> <div className="flex flex-col items-center gap-4 py-2">
<div className="flex gap-0.5"> <StarRating value={selected} onChange={handleRate} size="lg" />
{Array.from({ length: 10 }, (_, i) => i + 1).map((star) => {
const halfValue = star - 0.5;
return (
<div key={star} className="relative h-8 w-8">
{/* Left half — half star */}
<button
className="absolute inset-y-0 left-0 w-1/2 z-10 focus:outline-none"
onMouseEnter={() => setHovered(halfValue)}
onMouseLeave={() => setHovered(null)}
onClick={() => handleRate(halfValue)}
/>
{/* Right half — full star */}
<button
className="absolute inset-y-0 right-0 w-1/2 z-10 focus:outline-none"
onMouseEnter={() => setHovered(star)}
onMouseLeave={() => setHovered(null)}
onClick={() => handleRate(star)}
/>
{/* Star icon */}
<div className="pointer-events-none transition-transform hover:scale-125">
{displayRating >= star ? (
<Star className="h-8 w-8 fill-yellow-400 text-yellow-400 transition-colors" />
) : displayRating >= halfValue ? (
<div className="relative h-8 w-8">
<Star className="absolute h-8 w-8 text-muted-foreground/30 transition-colors" />
<div className="absolute inset-0 overflow-hidden w-1/2">
<Star className="h-8 w-8 fill-yellow-400 text-yellow-400 transition-colors" />
</div>
</div>
) : (
<Star className="h-8 w-8 text-muted-foreground/30 transition-colors" />
)}
</div>
</div>
);
})}
</div>
<p className="text-xl font-semibold tabular-nums"> <p className="text-xl font-semibold tabular-nums">
{displayRating > 0 ? `${displayRating} / 10` : '—'} {selected > 0 ? `${selected} / 10` : '—'}
</p> </p>
{(selected > 0 || currentRating > 0) && ( {(selected > 0 || currentRating > 0) && (
@@ -2,24 +2,38 @@ import { Link } from 'react-router-dom';
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
import { ScrollArea, ScrollBar } from '@/components/ui/scroll-area'; import { ScrollArea, ScrollBar } from '@/components/ui/scroll-area';
import { getProfileUrl } from '@/lib/media-utils'; import { getProfileUrl } from '@/lib/media-utils';
import { ChevronRight } from 'lucide-react';
import type { Credit } from '@/types'; import type { Credit } from '@/types';
interface CastListProps { interface CastListProps {
credits: Credit[]; credits: Credit[];
entryId?: number;
isTvSeries?: boolean;
} }
export function CastList({ credits }: CastListProps) { export function CastList({ credits, entryId, isTvSeries }: CastListProps) {
const castCredits = credits.filter((c) => c.cast_type === 'cast'); const castCredits = credits.filter((c) => c.cast_type === 'cast');
if (castCredits.length === 0) return null; if (castCredits.length === 0) return null;
return ( return (
<div className="space-y-3"> <div className="space-y-3">
<h3 className="text-lg font-semibold">Cast</h3> <div className="flex items-center justify-between">
<h3 className="text-lg font-semibold">Cast</h3>
{entryId != null && (
<Link
to={`/entry/${entryId}/cast`}
className="inline-flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors"
>
All Cast &amp; Crew
<ChevronRight className="h-4 w-4" />
</Link>
)}
</div>
<ScrollArea className="w-full"> <ScrollArea className="w-full">
<div className="flex gap-4 pb-4"> <div className="flex gap-4 pb-4">
{castCredits.map((credit) => ( {castCredits.map((credit) => (
<CastCard key={credit.id} credit={credit} /> <CastCard key={credit.id} credit={credit} isTvSeries={isTvSeries} />
))} ))}
</div> </div>
<ScrollBar orientation="horizontal" /> <ScrollBar orientation="horizontal" />
@@ -28,7 +42,7 @@ export function CastList({ credits }: CastListProps) {
); );
} }
function CastCard({ credit }: { credit: Credit }) { function CastCard({ credit, isTvSeries }: { credit: Credit; isTvSeries?: boolean }) {
const profileUrl = credit.people?.profile_path const profileUrl = credit.people?.profile_path
? getProfileUrl(credit.people.profile_path) ? getProfileUrl(credit.people.profile_path)
: undefined; : undefined;
@@ -59,6 +73,11 @@ function CastCard({ credit }: { credit: Credit }) {
<p className="text-[10px] text-muted-foreground leading-tight line-clamp-1"> <p className="text-[10px] text-muted-foreground leading-tight line-clamp-1">
{credit.character} {credit.character}
</p> </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> </div>
</Link> </Link>
); );
@@ -0,0 +1,72 @@
import { useState } from 'react';
import { Star } from 'lucide-react';
interface StarRatingProps {
value: number;
onChange?: (rating: number) => void;
max?: number;
size?: 'sm' | 'md' | 'lg';
readOnly?: boolean;
}
const sizeMap = {
sm: 'h-4 w-4',
md: 'h-6 w-6',
lg: 'h-8 w-8',
};
export function StarRating({
value,
onChange,
max = 10,
size = 'lg',
readOnly = false,
}: StarRatingProps) {
const [hovered, setHovered] = useState<number | null>(null);
const displayRating = hovered ?? value;
const iconClass = sizeMap[size];
return (
<div className="flex gap-0.5">
{Array.from({ length: max }, (_, i) => i + 1).map((star) => {
const halfValue = star - 0.5;
return (
<div key={star} className={`relative ${iconClass}`}>
{!readOnly && (
<>
<button
type="button"
className="absolute inset-y-0 left-0 w-1/2 z-10 focus:outline-none"
onMouseEnter={() => setHovered(halfValue)}
onMouseLeave={() => setHovered(null)}
onClick={() => onChange?.(halfValue === value ? 0 : halfValue)}
/>
<button
type="button"
className="absolute inset-y-0 right-0 w-1/2 z-10 focus:outline-none"
onMouseEnter={() => setHovered(star)}
onMouseLeave={() => setHovered(null)}
onClick={() => onChange?.(star === value ? 0 : star)}
/>
</>
)}
<div className="pointer-events-none">
{displayRating >= star ? (
<Star className={`${iconClass} fill-yellow-400 text-yellow-400 transition-colors`} />
) : displayRating >= halfValue ? (
<div className={`relative ${iconClass}`}>
<Star className={`absolute ${iconClass} text-muted-foreground/30 transition-colors`} />
<div className="absolute inset-0 overflow-hidden w-1/2">
<Star className={`${iconClass} fill-yellow-400 text-yellow-400 transition-colors`} />
</div>
</div>
) : (
<Star className={`${iconClass} text-muted-foreground/30 transition-colors`} />
)}
</div>
</div>
);
})}
</div>
);
}
+200
View File
@@ -0,0 +1,200 @@
import { useState, useMemo } from 'react';
import { useParams, Link } from 'react-router-dom';
import { useEntry } from '@/hooks/useEntries';
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
import { Skeleton } from '@/components/ui/skeleton';
import { Button } from '@/components/ui/button';
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/components/ui/select';
import { getProfileUrl } from '@/lib/media-utils';
import { ArrowUpDown } from 'lucide-react';
import type { Credit } from '@/types';
type SortField = 'order' | 'popularity' | 'name' | 'birthday' | 'gender' | 'episode_count';
type SortDir = 'asc' | 'desc';
type CastFilter = 'all' | 'cast' | 'crew';
function sortCredits(credits: Credit[], field: SortField, dir: SortDir): Credit[] {
return [...credits].sort((a, b) => {
let cmp = 0;
switch (field) {
case 'order':
cmp = (a.order ?? 9999) - (b.order ?? 9999);
break;
case 'popularity':
cmp = (b.people?.popularity ?? 0) - (a.people?.popularity ?? 0);
break;
case 'name':
cmp = (a.people?.name ?? '').localeCompare(b.people?.name ?? '');
break;
case 'birthday': {
const da = a.people?.birthday ? new Date(a.people.birthday).getTime() : 0;
const db = b.people?.birthday ? new Date(b.people.birthday).getTime() : 0;
cmp = da - db;
break;
}
case 'gender':
cmp = (a.people?.gender ?? 0) - (b.people?.gender ?? 0);
break;
case 'episode_count':
cmp = (b.episode_count ?? 0) - (a.episode_count ?? 0);
break;
}
return dir === 'asc' ? cmp : -cmp;
});
}
export function EntryCastsPage() {
const { id } = useParams<{ id: string }>();
const entryId = parseInt(id!, 10);
const { data: entry, isLoading } = useEntry(entryId);
const [sortField, setSortField] = useState<SortField>('order');
const [sortDir, setSortDir] = useState<SortDir>('asc');
const [filter, setFilter] = useState<CastFilter>('all');
const filtered = useMemo(() => {
if (!entry?.credits) return [];
if (filter === 'cast') return entry.credits.filter((c) => c.cast_type === 'cast');
if (filter === 'crew') return entry.credits.filter((c) => c.cast_type === 'crew');
return entry.credits;
}, [entry?.credits, filter]);
const sorted = useMemo(() => sortCredits(filtered, sortField, sortDir), [filtered, sortField, sortDir]);
if (isLoading || !entry) {
return (
<div className="space-y-6 mx-auto max-w-4xl">
<Skeleton className="h-5 w-64" />
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6">
{Array.from({ length: 18 }).map((_, i) => (
<div key={i} className="flex flex-col items-center gap-2">
<Skeleton className="h-24 w-24 rounded-full" />
<Skeleton className="h-4 w-20" />
</div>
))}
</div>
</div>
);
}
const isTv = entry.is_tvseries;
return (
<div className="space-y-6 animate-page-enter mx-auto max-w-4xl">
{/* Breadcrumb */}
<div className="flex items-center gap-1.5 text-sm text-muted-foreground">
<Link
to={`/entry/${entryId}`}
className="hover:text-foreground transition-colors truncate max-w-60"
>
{entry.title}
</Link>
<span>/</span>
<span className="text-foreground font-medium">Cast &amp; Crew</span>
</div>
{/* Controls */}
<div className="flex flex-wrap items-center gap-3">
<Select value={filter} onValueChange={(v) => setFilter(v as CastFilter)}>
<SelectTrigger className="w-32">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="all">All</SelectItem>
<SelectItem value="cast">Cast</SelectItem>
<SelectItem value="crew">Crew</SelectItem>
</SelectContent>
</Select>
<Select value={sortField} onValueChange={(v) => setSortField(v as SortField)}>
<SelectTrigger className="w-40">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="order">Credit Order</SelectItem>
<SelectItem value="popularity">Popularity</SelectItem>
<SelectItem value="name">Name</SelectItem>
<SelectItem value="birthday">Birthday</SelectItem>
<SelectItem value="gender">Gender</SelectItem>
{isTv && <SelectItem value="episode_count">Episodes</SelectItem>}
</SelectContent>
</Select>
<Button
variant="ghost"
size="icon"
className="h-9 w-9"
onClick={() => setSortDir((d) => (d === 'asc' ? 'desc' : 'asc'))}
>
<ArrowUpDown className="h-4 w-4" />
</Button>
<span className="text-sm text-muted-foreground ml-auto">
{sorted.length} {sorted.length === 1 ? 'credit' : 'credits'}
</span>
</div>
{/* Grid */}
{sorted.length === 0 ? (
<p className="text-center text-muted-foreground py-12">No credits found.</p>
) : (
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6">
{sorted.map((credit) => (
<CreditCard key={credit.id} credit={credit} isTv={isTv} />
))}
</div>
)}
</div>
);
}
function CreditCard({ credit, isTv }: { credit: Credit; isTv: boolean }) {
const profileUrl = credit.people?.profile_path
? getProfileUrl(credit.people.profile_path)
: undefined;
const personLink = credit.entry_id
? `/people/${credit.people_id}`
: `/people/tmdb/${credit.people?.tmdb_id ?? credit.people_id}`;
const roleLabel =
credit.cast_type === 'cast'
? credit.character
: credit.job || credit.department;
return (
<Link
to={personLink}
className="group flex flex-col items-center gap-2 text-center p-2 rounded-lg hover:bg-accent/50 transition-colors"
>
<Avatar className="h-20 w-20 transition-transform group-hover:scale-105">
<AvatarImage src={profileUrl} alt={credit.people?.name} />
<AvatarFallback className="text-xs">
{credit.people?.name
?.split(' ')
.map((n) => n[0])
.join('')}
</AvatarFallback>
</Avatar>
<div className="min-w-0 w-full">
<p className="text-xs font-medium leading-tight line-clamp-2">{credit.people?.name}</p>
{roleLabel && (
<p className="text-[10px] text-muted-foreground leading-tight line-clamp-1 mt-0.5">
{roleLabel}
</p>
)}
{isTv && credit.episode_count != null && credit.episode_count > 0 && (
<p className="text-[10px] text-muted-foreground/70 leading-tight mt-0.5">
{credit.episode_count} {credit.episode_count === 1 ? 'episode' : 'episodes'}
</p>
)}
</div>
</Link>
);
}
@@ -380,7 +380,7 @@ export function EntryDetailsPage() {
{e.credits && e.credits.length > 0 && ( {e.credits && e.credits.length > 0 && (
<> <>
<Separator /> <Separator />
<CastList credits={e.credits} /> <CastList credits={e.credits} entryId={e.id} isTvSeries={e.is_tvseries} />
</> </>
)} )}
+13
View File
@@ -63,6 +63,11 @@ const SeasonPage = lazy(() =>
const EpisodePage = lazy(() => const EpisodePage = lazy(() =>
import('@/pages/EpisodePage').then((m) => ({ default: m.EpisodePage })) import('@/pages/EpisodePage').then((m) => ({ default: m.EpisodePage }))
); );
const EntryCastsPage = lazy(() =>
import('@/pages/EntryCastsPage').then((m) => ({
default: m.EntryCastsPage,
}))
);
const PeoplePage = lazy(() => const PeoplePage = lazy(() =>
import('@/pages/PeoplePage').then((m) => ({ default: m.PeoplePage })) import('@/pages/PeoplePage').then((m) => ({ default: m.PeoplePage }))
); );
@@ -185,6 +190,14 @@ export const router = createBrowserRouter([
</SuspensePage> </SuspensePage>
), ),
}, },
{
path: '/entry/:id/cast',
element: (
<SuspensePage fallback={<PeopleSkeleton />}>
<EntryCastsPage />
</SuspensePage>
),
},
{ {
path: '/entry/:entryId/season/:seasonId', path: '/entry/:entryId/season/:seasonId',
element: ( element: (
+1
View File
@@ -151,6 +151,7 @@ export interface People {
biography: string | null; biography: string | null;
place_of_birth: string | null; place_of_birth: string | null;
known_for_department: string | null; known_for_department: string | null;
popularity: number | null;
fully_fetched: boolean; fully_fetched: boolean;
favorite: boolean; favorite: boolean;
pinned: boolean; pinned: boolean;