diff --git a/docs-vault/Components.md b/docs-vault/Components.md index 84cee18..6cb62a4 100644 --- a/docs-vault/Components.md +++ b/docs-vault/Components.md @@ -78,6 +78,24 @@ See [[Statistics]] for data details. 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. diff --git a/docs-vault/Pages.md b/docs-vault/Pages.md index e80660f..ac5227f 100644 --- a/docs-vault/Pages.md +++ b/docs-vault/Pages.md @@ -66,9 +66,20 @@ Sections: - Actions: watchlist, favorite, refresh, settings, rating - Watch history (movies) → [[Watch Tracking]] - 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]] +## 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 Season detail with episode list. Width: `max-w-4xl`. diff --git a/react_frontend/src/components/dialogs/CollectionEditDialog.tsx b/react_frontend/src/components/dialogs/CollectionEditDialog.tsx index f7ea42c..c22bfbe 100644 --- a/react_frontend/src/components/dialogs/CollectionEditDialog.tsx +++ b/react_frontend/src/components/dialogs/CollectionEditDialog.tsx @@ -10,7 +10,8 @@ import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; 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 type { Collection } from '@/types'; @@ -30,7 +31,6 @@ export function CollectionEditDialog({ const [userRating, setUserRating] = useState( collection.user_rating ?? 0 ); - const [hoveredStar, setHoveredStar] = useState(null); const [posterFile, setPosterFile] = useState(null); const [backdropFile, setBackdropFile] = useState(null); const [posterPreview, setPosterPreview] = useState(null); @@ -107,30 +107,8 @@ export function CollectionEditDialog({
-
-
- {Array.from({ length: 10 }, (_, i) => i + 1).map((star) => { - const displayRating = hoveredStar ?? userRating; - return ( - - ); - })} -
+
+ {userRating > 0 ? `${userRating}/10` : '—'} diff --git a/react_frontend/src/components/dialogs/EntrySettingsDialog.tsx b/react_frontend/src/components/dialogs/EntrySettingsDialog.tsx index adcb339..418066b 100644 --- a/react_frontend/src/components/dialogs/EntrySettingsDialog.tsx +++ b/react_frontend/src/components/dialogs/EntrySettingsDialog.tsx @@ -7,10 +7,8 @@ import { import { Label } from '@/components/ui/label'; import { Switch } from '@/components/ui/switch'; import { Separator } from '@/components/ui/separator'; -import { useUpdateEntry } from '@/hooks/useEntries'; -import { RatingDialog } from '@/components/dialogs/RatingDialog'; -import { useState } from 'react'; -import { Star } from 'lucide-react'; +import { useUpdateEntry, useUpdateEntryRatings } from '@/hooks/useEntries'; +import { StarRating } from '@/components/ui/star-rating'; import type { Entry } from '@/types'; interface EntrySettingsDialogProps { @@ -25,7 +23,7 @@ export function EntrySettingsDialog({ entry, }: EntrySettingsDialogProps) { const updateEntry = useUpdateEntry(); - const [showRating, setShowRating] = useState(false); + const updateRatings = useUpdateEntryRatings(); const handleToggle = (field: keyof Entry, value: boolean) => { updateEntry.mutate({ id: entry.id, data: { [field]: value } }); @@ -39,62 +37,47 @@ export function EntrySettingsDialog({ { 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 ( - <> - - - - Entry Settings -

{entry.title}

-
-
- {boolSettings.map(({ field, label }) => ( -
- - handleToggle(field, checked)} - /> -
- ))} - -
- - + + + + Entry Settings +

{entry.title}

+
+
+ {boolSettings.map(({ field, label }) => ( +
+ + handleToggle(field, checked)} + /> +
+ ))} + +
+ +
+ + + {userRating > 0 ? `${userRating}/10` : '—'} +
- -
- - - +
+ +
); } diff --git a/react_frontend/src/components/dialogs/RatingDialog.tsx b/react_frontend/src/components/dialogs/RatingDialog.tsx index fe73cc9..8c795b6 100644 --- a/react_frontend/src/components/dialogs/RatingDialog.tsx +++ b/react_frontend/src/components/dialogs/RatingDialog.tsx @@ -6,7 +6,7 @@ import { DialogTitle, } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; -import { Star } from 'lucide-react'; +import { StarRating } from '@/components/ui/star-rating'; import { useUpdateEntryRatings } from '@/hooks/useEntries'; import type { Entry } from '@/types'; @@ -18,27 +18,18 @@ interface RatingDialogProps { export function RatingDialog({ open, onOpenChange, entry }: RatingDialogProps) { const currentRating = entry.entryRatings?.user_rating ?? 0; - const [hovered, setHovered] = useState(null); const [selected, setSelected] = useState(currentRating); const updateRatings = useUpdateEntryRatings(); - // Sync selected when dialog opens or entry rating changes useEffect(() => { - if (open) { - setSelected(entry.entryRatings?.user_rating ?? 0); - } + if (open) setSelected(entry.entryRatings?.user_rating ?? 0); }, [open, entry.entryRatings?.user_rating]); - const displayRating = hovered ?? selected; - const handleRate = (rating: number) => { setSelected(rating); updateRatings.mutate({ id: entry.id, - ratings: { - id: entry.entryRatings?.id, - user_rating: rating || null, - }, + ratings: { id: entry.entryRatings?.id, user_rating: rating || null }, }); onOpenChange(false); }; @@ -47,10 +38,7 @@ export function RatingDialog({ open, onOpenChange, entry }: RatingDialogProps) { setSelected(0); updateRatings.mutate({ id: entry.id, - ratings: { - id: entry.entryRatings?.id, - user_rating: null, - }, + ratings: { id: entry.entryRatings?.id, user_rating: null }, }); onOpenChange(false); }; @@ -64,47 +52,10 @@ export function RatingDialog({ open, onOpenChange, entry }: RatingDialogProps) {
-
- {Array.from({ length: 10 }, (_, i) => i + 1).map((star) => { - const halfValue = star - 0.5; - return ( -
- {/* Left half — half star */} -
- ); - })} -
+

- {displayRating > 0 ? `${displayRating} / 10` : '—'} + {selected > 0 ? `${selected} / 10` : '—'}

{(selected > 0 || currentRating > 0) && ( diff --git a/react_frontend/src/components/entries/CastList.tsx b/react_frontend/src/components/entries/CastList.tsx index fbff339..dbb669c 100644 --- a/react_frontend/src/components/entries/CastList.tsx +++ b/react_frontend/src/components/entries/CastList.tsx @@ -2,24 +2,38 @@ 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; } -export function CastList({ credits }: CastListProps) { +export function CastList({ credits, entryId, isTvSeries }: CastListProps) { const castCredits = credits.filter((c) => c.cast_type === 'cast'); if (castCredits.length === 0) return null; return (
-

Cast

+
+

Cast

+ {entryId != null && ( + + All Cast & Crew + + + )} +
{castCredits.map((credit) => ( - + ))}
@@ -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 ? getProfileUrl(credit.people.profile_path) : undefined; @@ -59,6 +73,11 @@ function CastCard({ credit }: { credit: Credit }) {

{credit.character}

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

+ {credit.episode_count} ep. +

+ )}
); diff --git a/react_frontend/src/components/ui/star-rating.tsx b/react_frontend/src/components/ui/star-rating.tsx new file mode 100644 index 0000000..3d7867b --- /dev/null +++ b/react_frontend/src/components/ui/star-rating.tsx @@ -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(null); + const displayRating = hovered ?? value; + const iconClass = sizeMap[size]; + + return ( +
+ {Array.from({ length: max }, (_, i) => i + 1).map((star) => { + const halfValue = star - 0.5; + return ( +
+ {!readOnly && ( + <> +
+ ); + })} +
+ ); +} diff --git a/react_frontend/src/pages/EntryCastsPage.tsx b/react_frontend/src/pages/EntryCastsPage.tsx new file mode 100644 index 0000000..d5c088d --- /dev/null +++ b/react_frontend/src/pages/EntryCastsPage.tsx @@ -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('order'); + const [sortDir, setSortDir] = useState('asc'); + const [filter, setFilter] = useState('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 ( +
+ +
+ {Array.from({ length: 18 }).map((_, i) => ( +
+ + +
+ ))} +
+
+ ); + } + + const isTv = entry.is_tvseries; + + return ( +
+ {/* Breadcrumb */} +
+ + {entry.title} + + / + Cast & Crew +
+ + {/* Controls */} +
+ + + + + + + + {sorted.length} {sorted.length === 1 ? 'credit' : 'credits'} + +
+ + {/* Grid */} + {sorted.length === 0 ? ( +

No credits found.

+ ) : ( +
+ {sorted.map((credit) => ( + + ))} +
+ )} +
+ ); +} + +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 ( + + + + + {credit.people?.name + ?.split(' ') + .map((n) => n[0]) + .join('')} + + +
+

{credit.people?.name}

+ {roleLabel && ( +

+ {roleLabel} +

+ )} + {isTv && credit.episode_count != null && credit.episode_count > 0 && ( +

+ {credit.episode_count} {credit.episode_count === 1 ? 'episode' : 'episodes'} +

+ )} +
+ + ); +} diff --git a/react_frontend/src/pages/EntryDetailsPage.tsx b/react_frontend/src/pages/EntryDetailsPage.tsx index e93c069..0854845 100644 --- a/react_frontend/src/pages/EntryDetailsPage.tsx +++ b/react_frontend/src/pages/EntryDetailsPage.tsx @@ -380,7 +380,7 @@ export function EntryDetailsPage() { {e.credits && e.credits.length > 0 && ( <> - + )} diff --git a/react_frontend/src/router.tsx b/react_frontend/src/router.tsx index 61e3eeb..692e2fa 100644 --- a/react_frontend/src/router.tsx +++ b/react_frontend/src/router.tsx @@ -63,6 +63,11 @@ const SeasonPage = lazy(() => const EpisodePage = lazy(() => import('@/pages/EpisodePage').then((m) => ({ default: m.EpisodePage })) ); +const EntryCastsPage = lazy(() => + import('@/pages/EntryCastsPage').then((m) => ({ + default: m.EntryCastsPage, + })) +); const PeoplePage = lazy(() => import('@/pages/PeoplePage').then((m) => ({ default: m.PeoplePage })) ); @@ -185,6 +190,14 @@ export const router = createBrowserRouter([ ), }, + { + path: '/entry/:id/cast', + element: ( + }> + + + ), + }, { path: '/entry/:entryId/season/:seasonId', element: ( diff --git a/react_frontend/src/types/index.ts b/react_frontend/src/types/index.ts index 9933367..9b55007 100644 --- a/react_frontend/src/types/index.ts +++ b/react_frontend/src/types/index.ts @@ -151,6 +151,7 @@ export interface People { biography: string | null; place_of_birth: string | null; known_for_department: string | null; + popularity: number | null; fully_fetched: boolean; favorite: boolean; pinned: boolean;