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

@@ -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<number | null>(null);
const [selected, setSelected] = useState<number>(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) {
</DialogHeader>
<div className="flex flex-col items-center gap-4 py-2">
<div className="flex gap-0.5">
{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>
<StarRating value={selected} onChange={handleRate} size="lg" />
<p className="text-xl font-semibold tabular-nums">
{displayRating > 0 ? `${displayRating} / 10` : '—'}
{selected > 0 ? `${selected} / 10` : '—'}
</p>
{(selected > 0 || currentRating > 0) && (