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:
1 parent
b3002a329d
commit
e460290b9b
11 files changed
+392
-146
No files matched your search
@@ -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 (
|
||||
<>
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="sm:max-w-md">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Entry Settings</DialogTitle>
|
||||
<p className="text-sm text-muted-foreground line-clamp-1">{entry.title}</p>
|
||||
</DialogHeader>
|
||||
<div className="space-y-1 py-2">
|
||||
{boolSettings.map(({ field, label }) => (
|
||||
<div key={field} className="flex items-center justify-between rounded-lg px-1 py-2.5">
|
||||
<Label htmlFor={field} className="cursor-pointer">
|
||||
{label}
|
||||
</Label>
|
||||
<Switch
|
||||
id={field}
|
||||
checked={!!entry[field]}
|
||||
onCheckedChange={(checked) => handleToggle(field, checked)}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
<Separator className="my-2" />
|
||||
<div className="flex items-center justify-between rounded-lg px-1 py-2.5">
|
||||
<Label className="cursor-pointer">Your Rating</Label>
|
||||
<button
|
||||
className="flex items-center gap-1.5 text-sm font-medium hover:text-primary transition-colors"
|
||||
onClick={() => setShowRating(true)}
|
||||
>
|
||||
{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>
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="sm:max-w-md">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Entry Settings</DialogTitle>
|
||||
<p className="text-sm text-muted-foreground line-clamp-1">{entry.title}</p>
|
||||
</DialogHeader>
|
||||
<div className="space-y-1 py-2">
|
||||
{boolSettings.map(({ field, label }) => (
|
||||
<div key={field} className="flex items-center justify-between rounded-lg px-1 py-2.5">
|
||||
<Label htmlFor={field} className="cursor-pointer">
|
||||
{label}
|
||||
</Label>
|
||||
<Switch
|
||||
id={field}
|
||||
checked={!!entry[field]}
|
||||
onCheckedChange={(checked) => handleToggle(field, checked)}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
<Separator className="my-2" />
|
||||
<div className="space-y-2 rounded-lg px-1 py-2.5">
|
||||
<Label>Your Rating</Label>
|
||||
<div className="flex items-center gap-3">
|
||||
<StarRating value={userRating} onChange={handleRatingChange} size="sm" />
|
||||
<span className="text-sm text-muted-foreground tabular-nums">
|
||||
{userRating > 0 ? `${userRating}/10` : '—'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
<RatingDialog
|
||||
open={showRating}
|
||||
onOpenChange={setShowRating}
|
||||
entry={entry}
|
||||
/>
|
||||
</>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user