feat(frontend): Entry details redesign, people filmography, calendar improvements
- EntryDetailsPage: sticky poster layout, centered max-w-4xl, director by-line with link, rating pills (IMDb/TMDB/You), quick actions under poster, RatingDialog with star UI, In Collections section using backdrops, EntrySettingsDialog with show_in_calendar / auto_sync / rating options - RatingDialog: new component with 10-star interactive rating - AddEntryToCollectionDialog: optimistic cache updates so checkbox state reflects immediately and In Collections section on entry details page refreshes - PersonDetailsPage: filmography section showing library vs. non-library entries via person.roles, TMDB combined credits for non-library titles - PersonTmdbRedirectPage: new redirect page for TMDB person IDs to local person ID - PeoplePage: fix person card links to use /people/tmdb/:tmdbId - CalendarPage: full-height layout, larger episode thumbnails, episode items clickable, improved tooltip, show_in_calendar backend filter - Fix useUpdateEntry to also invalidate entryKeys.all (favorite button reactivity) - Fix updateRatings API body wrapping - Add useUpdateEntryRatings, usePersonCredits, useFetchPersonByTmdbId hooks - Add getCollectionBackdropUrl to media-utils - Types: show_in_calendar, auto_sync on Entry; id on EntryRatings; roles on People - Backend: fix fetchPersonData alias in peopleService; remove duplicate getPersonCredits; add show_in_calendar filter to episodeService
This commit is contained in:
1 parent
11eab03987
commit
3ca24434d7
16 files changed
+857
-322
No files matched your search
@@ -9,35 +9,69 @@ import { Input } from '@/components/ui/input';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
import { ScrollArea } from '@/components/ui/scroll-area';
|
||||
import { useCollections } from '@/hooks/useCollections';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import { collectionsApi } from '@/api/collections';
|
||||
import { collectionKeys } from '@/hooks/useCollections';
|
||||
import type { Collection } from '@/types';
|
||||
|
||||
interface AddEntryToCollectionDialogProps {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
entryId: number;
|
||||
entryCollections?: Collection[];
|
||||
}
|
||||
|
||||
export function AddEntryToCollectionDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
entryId,
|
||||
entryCollections = [],
|
||||
}: AddEntryToCollectionDialogProps) {
|
||||
const [search, setSearch] = useState('');
|
||||
const [pending, setPending] = useState<Set<number>>(new Set());
|
||||
const { data: allCollections = [] } = useCollections();
|
||||
const entryCollectionIds = new Set(entryCollections.map((c) => c.id));
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const filtered = allCollections.filter((c) =>
|
||||
c.name.toLowerCase().includes(search.toLowerCase())
|
||||
);
|
||||
|
||||
const isInCollection = (collectionId: number) =>
|
||||
allCollections
|
||||
.find((c) => c.id === collectionId)
|
||||
?.entries?.some((e) => e.id === entryId) ?? false;
|
||||
|
||||
const handleToggle = async (collectionId: number, checked: boolean) => {
|
||||
if (checked) {
|
||||
await collectionsApi.addEntry(collectionId, entryId);
|
||||
} else {
|
||||
await collectionsApi.removeEntry(collectionId, entryId);
|
||||
setPending((prev) => new Set(prev).add(collectionId));
|
||||
|
||||
// Optimistically update the cache so the checkbox reflects immediately
|
||||
queryClient.setQueryData<Collection[]>(collectionKeys.all, (old) =>
|
||||
old?.map((col) => {
|
||||
if (col.id !== collectionId) return col;
|
||||
if (checked) {
|
||||
// Add a stub entry so isInCollection() returns true right away
|
||||
const entries = col.entries ?? [];
|
||||
const already = entries.some((e) => e.id === entryId);
|
||||
if (already) return col;
|
||||
return { ...col, entries: [...entries, { id: entryId } as Collection['entries'][0]] };
|
||||
} else {
|
||||
return { ...col, entries: (col.entries ?? []).filter((e) => e.id !== entryId) };
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
try {
|
||||
if (checked) {
|
||||
await collectionsApi.addEntry(collectionId, entryId);
|
||||
} else {
|
||||
await collectionsApi.removeEntry(collectionId, entryId);
|
||||
}
|
||||
} finally {
|
||||
setPending((prev) => {
|
||||
const next = new Set(prev);
|
||||
next.delete(collectionId);
|
||||
return next;
|
||||
});
|
||||
// Refetch to get authoritative data (also refreshes CollectionsSection in EntryDetailsPage)
|
||||
queryClient.invalidateQueries({ queryKey: collectionKeys.all });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -54,20 +88,25 @@ export function AddEntryToCollectionDialog({
|
||||
/>
|
||||
<ScrollArea className="h-64">
|
||||
<div className="space-y-2 pr-4">
|
||||
{filtered.map((collection) => (
|
||||
<label
|
||||
key={collection.id}
|
||||
className="flex cursor-pointer items-center gap-3 rounded-lg p-2 hover:bg-accent/50"
|
||||
>
|
||||
<Checkbox
|
||||
checked={entryCollectionIds.has(collection.id)}
|
||||
onCheckedChange={(checked) =>
|
||||
handleToggle(collection.id, !!checked)
|
||||
}
|
||||
/>
|
||||
<span className="text-sm">{collection.name}</span>
|
||||
</label>
|
||||
))}
|
||||
{filtered.map((collection) => {
|
||||
const checked = isInCollection(collection.id);
|
||||
const loading = pending.has(collection.id);
|
||||
return (
|
||||
<label
|
||||
key={collection.id}
|
||||
className="flex cursor-pointer items-center gap-3 rounded-lg p-2 hover:bg-accent/50"
|
||||
>
|
||||
<Checkbox
|
||||
checked={checked}
|
||||
disabled={loading}
|
||||
onCheckedChange={(val) =>
|
||||
handleToggle(collection.id, !!val)
|
||||
}
|
||||
/>
|
||||
<span className="text-sm">{collection.name}</span>
|
||||
</label>
|
||||
);
|
||||
})}
|
||||
{filtered.length === 0 && (
|
||||
<p className="py-4 text-center text-sm text-muted-foreground">
|
||||
No collections found.
|
||||
|
||||
@@ -6,7 +6,11 @@ import {
|
||||
} from '@/components/ui/dialog';
|
||||
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 type { Entry } from '@/types';
|
||||
|
||||
interface EntrySettingsDialogProps {
|
||||
@@ -21,36 +25,76 @@ export function EntrySettingsDialog({
|
||||
entry,
|
||||
}: EntrySettingsDialogProps) {
|
||||
const updateEntry = useUpdateEntry();
|
||||
const [showRating, setShowRating] = useState(false);
|
||||
|
||||
const handleToggle = (field: keyof Entry, value: boolean) => {
|
||||
updateEntry.mutate({ id: entry.id, data: { [field]: value } });
|
||||
};
|
||||
|
||||
const settings = [
|
||||
const boolSettings = [
|
||||
{ field: 'favorit' as const, label: 'Favorite' },
|
||||
{ field: 'hidden' as const, label: 'Hidden' },
|
||||
{ field: 'watchlist' as const, label: 'Watchlist' },
|
||||
{ field: 'show_in_calendar' as const, label: 'Show in Calendar' },
|
||||
{ field: 'auto_sync' as const, label: 'Auto Sync' },
|
||||
];
|
||||
|
||||
const userRating = entry.entryRatings?.user_rating;
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="sm:max-w-md">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Entry Settings</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="space-y-4 py-4">
|
||||
{settings.map(({ field, label }) => (
|
||||
<div key={field} className="flex items-center justify-between">
|
||||
<Label htmlFor={field}>{label}</Label>
|
||||
<Switch
|
||||
id={field}
|
||||
checked={!!entry[field]}
|
||||
onCheckedChange={(checked) => handleToggle(field, checked)}
|
||||
/>
|
||||
<>
|
||||
<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>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
<RatingDialog
|
||||
open={showRating}
|
||||
onOpenChange={setShowRating}
|
||||
entry={entry}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
import { useState } from 'react';
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from '@/components/ui/dialog';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Star } from 'lucide-react';
|
||||
import { useUpdateEntryRatings } from '@/hooks/useEntries';
|
||||
import type { Entry } from '@/types';
|
||||
|
||||
interface RatingDialogProps {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
entry: Entry;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
const displayRating = hovered ?? selected;
|
||||
|
||||
const handleRate = (rating: number) => {
|
||||
setSelected(rating);
|
||||
updateRatings.mutate({
|
||||
id: entry.id,
|
||||
ratings: {
|
||||
id: entry.entryRatings?.id,
|
||||
user_rating: rating || null,
|
||||
},
|
||||
});
|
||||
onOpenChange(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="w-auto sm:max-w-none">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Rate</DialogTitle>
|
||||
<p className="text-sm text-muted-foreground line-clamp-1">{entry.title}</p>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="flex flex-col items-center gap-4 py-2">
|
||||
<div className="flex gap-1.5">
|
||||
{Array.from({ length: 10 }, (_, i) => i + 1).map((star) => (
|
||||
<button
|
||||
key={star}
|
||||
className="transition-transform hover:scale-125 focus:outline-none"
|
||||
onMouseEnter={() => setHovered(star)}
|
||||
onMouseLeave={() => setHovered(null)}
|
||||
onClick={() => handleRate(star)}
|
||||
>
|
||||
<Star
|
||||
className={`h-8 w-8 transition-colors ${
|
||||
star <= displayRating
|
||||
? 'fill-yellow-400 text-yellow-400'
|
||||
: 'text-muted-foreground/30'
|
||||
}`}
|
||||
/>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<p className="text-xl font-semibold tabular-nums">
|
||||
{displayRating > 0 ? `${displayRating} / 10` : '—'}
|
||||
</p>
|
||||
|
||||
{selected > 0 && (
|
||||
<Button variant="ghost" size="sm" onClick={() => handleRate(0)}>
|
||||
Clear rating
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user