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
@@ -31,7 +31,7 @@ export const collectionsApi = {
|
|||||||
|
|
||||||
addEntry: (collectionId: number, entryId: number) =>
|
addEntry: (collectionId: number, entryId: number) =>
|
||||||
api
|
api
|
||||||
.post(`/collections/${collectionId}/entries`, { entry_id: entryId })
|
.post(`/collections/${collectionId}/entries/${entryId}`, {})
|
||||||
.then((r) => r.data),
|
.then((r) => r.data),
|
||||||
|
|
||||||
removeEntry: (collectionId: number, entryId: number) =>
|
removeEntry: (collectionId: number, entryId: number) =>
|
||||||
|
|||||||
@@ -13,17 +13,18 @@ export const entriesApi = {
|
|||||||
api.post<Entry>('/entries', { tmdb_id, is_tvserie }).then((r) => normalizeEntry(r.data)),
|
api.post<Entry>('/entries', { tmdb_id, is_tvserie }).then((r) => normalizeEntry(r.data)),
|
||||||
|
|
||||||
update: (id: number, data: Partial<Entry>) =>
|
update: (id: number, data: Partial<Entry>) =>
|
||||||
api.put<Entry>(`/entries/${id}`, data).then((r) => normalizeEntry(r.data)),
|
api.put<Entry>(`/entries/${id}`, { entryData: data }).then((r) => normalizeEntry(r.data)),
|
||||||
|
|
||||||
updateRatings: (
|
updateRatings: (
|
||||||
id: number,
|
id: number,
|
||||||
ratings: {
|
ratings: {
|
||||||
|
id?: number;
|
||||||
user_rating?: number | null;
|
user_rating?: number | null;
|
||||||
tmdb_rating?: number | null;
|
tmdb_rating?: number | null;
|
||||||
imdb_rating?: number | null;
|
imdb_rating?: number | null;
|
||||||
rotten_tomatoes_rating?: number | null;
|
rotten_tomatoes_rating?: number | null;
|
||||||
}
|
}
|
||||||
) => api.put(`/entries/${id}/ratings`, ratings).then((r) => r.data),
|
) => api.put(`/entries/${id}/ratings`, { entryRatings: ratings }).then((r) => r.data),
|
||||||
|
|
||||||
updateIds: (
|
updateIds: (
|
||||||
id: number,
|
id: number,
|
||||||
|
|||||||
@@ -1,9 +1,37 @@
|
|||||||
import { api } from '@/lib/api';
|
import { api } from '@/lib/api';
|
||||||
import type { People } from '@/types';
|
import type { People, Credit } from '@/types';
|
||||||
|
|
||||||
|
export interface TmdbFilmographyItem {
|
||||||
|
id: number;
|
||||||
|
title?: string;
|
||||||
|
name?: string;
|
||||||
|
poster_path: string | null;
|
||||||
|
release_date?: string;
|
||||||
|
first_air_date?: string;
|
||||||
|
media_type: 'movie' | 'tv';
|
||||||
|
character?: string;
|
||||||
|
job?: string;
|
||||||
|
department?: string;
|
||||||
|
credit_id?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TmdbFilmographyResponse {
|
||||||
|
cast: TmdbFilmographyItem[];
|
||||||
|
crew: TmdbFilmographyItem[];
|
||||||
|
}
|
||||||
|
|
||||||
export const peopleApi = {
|
export const peopleApi = {
|
||||||
getAll: () => api.get<People[]>('/people').then((r) => r.data),
|
getAll: () => api.get<People[]>('/people').then((r) => r.data),
|
||||||
|
|
||||||
getById: (id: number) =>
|
getById: (id: number) =>
|
||||||
api.get<People>(`/people/${id}`).then((r) => r.data),
|
api.get<People>(`/people/${id}`).then((r) => r.data),
|
||||||
|
|
||||||
|
getCredits: (id: number) =>
|
||||||
|
api.get<Credit[]>(`/people/${id}/credits`).then((r) => r.data),
|
||||||
|
|
||||||
|
getTmdbFilmography: (id: number) =>
|
||||||
|
api.get<TmdbFilmographyResponse>(`/people/${id}/tmdb-filmography`).then((r) => r.data),
|
||||||
|
|
||||||
|
fetchByTmdbId: (tmdb_id: number) =>
|
||||||
|
api.post<People>('/people/fetch', { tmdb_id }).then((r) => r.data),
|
||||||
};
|
};
|
||||||
@@ -9,35 +9,69 @@ import { Input } from '@/components/ui/input';
|
|||||||
import { Checkbox } from '@/components/ui/checkbox';
|
import { Checkbox } from '@/components/ui/checkbox';
|
||||||
import { ScrollArea } from '@/components/ui/scroll-area';
|
import { ScrollArea } from '@/components/ui/scroll-area';
|
||||||
import { useCollections } from '@/hooks/useCollections';
|
import { useCollections } from '@/hooks/useCollections';
|
||||||
|
import { useQueryClient } from '@tanstack/react-query';
|
||||||
import { collectionsApi } from '@/api/collections';
|
import { collectionsApi } from '@/api/collections';
|
||||||
|
import { collectionKeys } from '@/hooks/useCollections';
|
||||||
import type { Collection } from '@/types';
|
import type { Collection } from '@/types';
|
||||||
|
|
||||||
interface AddEntryToCollectionDialogProps {
|
interface AddEntryToCollectionDialogProps {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
onOpenChange: (open: boolean) => void;
|
onOpenChange: (open: boolean) => void;
|
||||||
entryId: number;
|
entryId: number;
|
||||||
entryCollections?: Collection[];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function AddEntryToCollectionDialog({
|
export function AddEntryToCollectionDialog({
|
||||||
open,
|
open,
|
||||||
onOpenChange,
|
onOpenChange,
|
||||||
entryId,
|
entryId,
|
||||||
entryCollections = [],
|
|
||||||
}: AddEntryToCollectionDialogProps) {
|
}: AddEntryToCollectionDialogProps) {
|
||||||
const [search, setSearch] = useState('');
|
const [search, setSearch] = useState('');
|
||||||
|
const [pending, setPending] = useState<Set<number>>(new Set());
|
||||||
const { data: allCollections = [] } = useCollections();
|
const { data: allCollections = [] } = useCollections();
|
||||||
const entryCollectionIds = new Set(entryCollections.map((c) => c.id));
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
const filtered = allCollections.filter((c) =>
|
const filtered = allCollections.filter((c) =>
|
||||||
c.name.toLowerCase().includes(search.toLowerCase())
|
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) => {
|
const handleToggle = async (collectionId: number, checked: boolean) => {
|
||||||
if (checked) {
|
setPending((prev) => new Set(prev).add(collectionId));
|
||||||
await collectionsApi.addEntry(collectionId, entryId);
|
|
||||||
} else {
|
// Optimistically update the cache so the checkbox reflects immediately
|
||||||
await collectionsApi.removeEntry(collectionId, entryId);
|
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">
|
<ScrollArea className="h-64">
|
||||||
<div className="space-y-2 pr-4">
|
<div className="space-y-2 pr-4">
|
||||||
{filtered.map((collection) => (
|
{filtered.map((collection) => {
|
||||||
<label
|
const checked = isInCollection(collection.id);
|
||||||
key={collection.id}
|
const loading = pending.has(collection.id);
|
||||||
className="flex cursor-pointer items-center gap-3 rounded-lg p-2 hover:bg-accent/50"
|
return (
|
||||||
>
|
<label
|
||||||
<Checkbox
|
key={collection.id}
|
||||||
checked={entryCollectionIds.has(collection.id)}
|
className="flex cursor-pointer items-center gap-3 rounded-lg p-2 hover:bg-accent/50"
|
||||||
onCheckedChange={(checked) =>
|
>
|
||||||
handleToggle(collection.id, !!checked)
|
<Checkbox
|
||||||
}
|
checked={checked}
|
||||||
/>
|
disabled={loading}
|
||||||
<span className="text-sm">{collection.name}</span>
|
onCheckedChange={(val) =>
|
||||||
</label>
|
handleToggle(collection.id, !!val)
|
||||||
))}
|
}
|
||||||
|
/>
|
||||||
|
<span className="text-sm">{collection.name}</span>
|
||||||
|
</label>
|
||||||
|
);
|
||||||
|
})}
|
||||||
{filtered.length === 0 && (
|
{filtered.length === 0 && (
|
||||||
<p className="py-4 text-center text-sm text-muted-foreground">
|
<p className="py-4 text-center text-sm text-muted-foreground">
|
||||||
No collections found.
|
No collections found.
|
||||||
|
|||||||
@@ -6,7 +6,11 @@ import {
|
|||||||
} from '@/components/ui/dialog';
|
} from '@/components/ui/dialog';
|
||||||
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 { useUpdateEntry } from '@/hooks/useEntries';
|
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';
|
import type { Entry } from '@/types';
|
||||||
|
|
||||||
interface EntrySettingsDialogProps {
|
interface EntrySettingsDialogProps {
|
||||||
@@ -21,36 +25,76 @@ export function EntrySettingsDialog({
|
|||||||
entry,
|
entry,
|
||||||
}: EntrySettingsDialogProps) {
|
}: EntrySettingsDialogProps) {
|
||||||
const updateEntry = useUpdateEntry();
|
const updateEntry = useUpdateEntry();
|
||||||
|
const [showRating, setShowRating] = useState(false);
|
||||||
|
|
||||||
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 } });
|
||||||
};
|
};
|
||||||
|
|
||||||
const settings = [
|
const boolSettings = [
|
||||||
{ field: 'favorit' as const, label: 'Favorite' },
|
{ field: 'favorit' as const, label: 'Favorite' },
|
||||||
{ field: 'hidden' as const, label: 'Hidden' },
|
{ field: 'hidden' as const, label: 'Hidden' },
|
||||||
{ field: 'watchlist' as const, label: 'Watchlist' },
|
{ 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 (
|
return (
|
||||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
<>
|
||||||
<DialogContent className="sm:max-w-md">
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||||
<DialogHeader>
|
<DialogContent className="sm:max-w-md">
|
||||||
<DialogTitle>Entry Settings</DialogTitle>
|
<DialogHeader>
|
||||||
</DialogHeader>
|
<DialogTitle>Entry Settings</DialogTitle>
|
||||||
<div className="space-y-4 py-4">
|
<p className="text-sm text-muted-foreground line-clamp-1">{entry.title}</p>
|
||||||
{settings.map(({ field, label }) => (
|
</DialogHeader>
|
||||||
<div key={field} className="flex items-center justify-between">
|
<div className="space-y-1 py-2">
|
||||||
<Label htmlFor={field}>{label}</Label>
|
{boolSettings.map(({ field, label }) => (
|
||||||
<Switch
|
<div key={field} className="flex items-center justify-between rounded-lg px-1 py-2.5">
|
||||||
id={field}
|
<Label htmlFor={field} className="cursor-pointer">
|
||||||
checked={!!entry[field]}
|
{label}
|
||||||
onCheckedChange={(checked) => handleToggle(field, checked)}
|
</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>
|
||||||
))}
|
</div>
|
||||||
</div>
|
</DialogContent>
|
||||||
</DialogContent>
|
</Dialog>
|
||||||
</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>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -66,8 +66,11 @@ export function useUpdateEntry() {
|
|||||||
mutationFn: ({ id, data }: { id: number; data: Partial<Entry> }) =>
|
mutationFn: ({ id, data }: { id: number; data: Partial<Entry> }) =>
|
||||||
entriesApi.update(id, data),
|
entriesApi.update(id, data),
|
||||||
onSuccess: (entry) => {
|
onSuccess: (entry) => {
|
||||||
|
// Update library store immediately so the UI reflects the change
|
||||||
updateEntry(entry.id, entry);
|
updateEntry(entry.id, entry);
|
||||||
|
// Invalidate both the detail query and the library list
|
||||||
queryClient.invalidateQueries({ queryKey: entryKeys.detail(entry.id) });
|
queryClient.invalidateQueries({ queryKey: entryKeys.detail(entry.id) });
|
||||||
|
queryClient.invalidateQueries({ queryKey: entryKeys.all });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -98,6 +101,24 @@ export function useRefreshEntry() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useUpdateEntryRatings() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: ({
|
||||||
|
id,
|
||||||
|
ratings,
|
||||||
|
}: {
|
||||||
|
id: number;
|
||||||
|
ratings: Parameters<typeof entriesApi.updateRatings>[1];
|
||||||
|
}) => entriesApi.updateRatings(id, ratings),
|
||||||
|
onSuccess: (_data, { id }) => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: entryKeys.detail(id) });
|
||||||
|
queryClient.invalidateQueries({ queryKey: entryKeys.all });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export function useUploadMedia() {
|
export function useUploadMedia() {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery, useMutation } from '@tanstack/react-query';
|
||||||
import { peopleApi } from '@/api/people';
|
import { peopleApi } from '@/api/people';
|
||||||
|
|
||||||
export const peopleKeys = {
|
export const peopleKeys = {
|
||||||
all: ['people'] as const,
|
all: ['people'] as const,
|
||||||
detail: (id: number) => ['people', id] as const,
|
detail: (id: number) => ['people', id] as const,
|
||||||
|
credits: (id: number) => ['people', id, 'credits'] as const,
|
||||||
|
tmdbFilmography: (id: number) => ['people', id, 'tmdb-filmography'] as const,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function usePerson(id: number) {
|
export function usePerson(id: number) {
|
||||||
@@ -13,3 +15,26 @@ export function usePerson(id: number) {
|
|||||||
enabled: !!id,
|
enabled: !!id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function usePersonCredits(id: number) {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: peopleKeys.credits(id),
|
||||||
|
queryFn: () => peopleApi.getCredits(id),
|
||||||
|
enabled: !!id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function usePersonTmdbFilmography(id: number) {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: peopleKeys.tmdbFilmography(id),
|
||||||
|
queryFn: () => peopleApi.getTmdbFilmography(id),
|
||||||
|
enabled: !!id,
|
||||||
|
staleTime: 10 * 60 * 1000,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useFetchPersonByTmdbId() {
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: (tmdb_id: number) => peopleApi.fetchByTmdbId(tmdb_id),
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -59,6 +59,21 @@ export function getTmdbPosterUrl(
|
|||||||
return getTmdbImageUrl(posterPath, size);
|
return getTmdbImageUrl(posterPath, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getCollectionBackdropUrl(collection: Collection): string {
|
||||||
|
if (collection.medias) {
|
||||||
|
const selectedBackdrop = collection.medias.find(
|
||||||
|
(m: Media) => m.type === 'backdrop' && m.is_selected
|
||||||
|
);
|
||||||
|
if (selectedBackdrop?.path) {
|
||||||
|
return getMediaUrl('collections', 'backdrops', 'full', selectedBackdrop.path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (collection.backdrop_path) {
|
||||||
|
return getTmdbImageUrl(collection.backdrop_path, 'w780');
|
||||||
|
}
|
||||||
|
return getCollectionPosterUrl(collection);
|
||||||
|
}
|
||||||
|
|
||||||
export function getCollectionPosterUrl(collection: Collection): string {
|
export function getCollectionPosterUrl(collection: Collection): string {
|
||||||
if (collection.medias) {
|
if (collection.medias) {
|
||||||
const selectedPoster = collection.medias.find(
|
const selectedPoster = collection.medias.find(
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
import { useState, useMemo } from 'react';
|
import { useState, useMemo } from 'react';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
import { format, startOfMonth, endOfMonth, eachDayOfInterval, getDay, addMonths, subMonths, isSameDay } from 'date-fns';
|
import { format, startOfMonth, endOfMonth, eachDayOfInterval, getDay, addMonths, subMonths, isSameDay } from 'date-fns';
|
||||||
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { useEpisodesByMonth } from '@/hooks/useEpisodes';
|
import { useEpisodesByMonth } from '@/hooks/useEpisodes';
|
||||||
import { getTmdbPosterUrl } from '@/lib/media-utils';
|
import { getTmdbPosterUrl, getPosterUrl } from '@/lib/media-utils';
|
||||||
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
|
import { Tooltip, TooltipContent, TooltipTrigger, TooltipProvider } from '@/components/ui/tooltip';
|
||||||
|
import type { Episode } from '@/types';
|
||||||
|
|
||||||
const DAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
const DAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
||||||
|
|
||||||
@@ -35,8 +37,8 @@ export function CalendarPage() {
|
|||||||
}, [episodes]);
|
}, [episodes]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-6">
|
<div className="flex flex-col h-[calc(100vh-7rem)]">
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between mb-4 shrink-0">
|
||||||
<h1 className="text-2xl font-bold">Calendar</h1>
|
<h1 className="text-2xl font-bold">Calendar</h1>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Button
|
<Button
|
||||||
@@ -46,7 +48,7 @@ export function CalendarPage() {
|
|||||||
>
|
>
|
||||||
<ChevronLeft className="h-4 w-4" />
|
<ChevronLeft className="h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
<span className="min-w-[140px] text-center font-medium">
|
<span className="min-w-35 text-center font-medium">
|
||||||
{format(currentDate, 'MMMM yyyy')}
|
{format(currentDate, 'MMMM yyyy')}
|
||||||
</span>
|
</span>
|
||||||
<Button
|
<Button
|
||||||
@@ -59,81 +61,134 @@ export function CalendarPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Calendar Grid */}
|
{/* Calendar Grid — fills remaining height */}
|
||||||
<div className="rounded-lg border border-border overflow-hidden">
|
<TooltipProvider>
|
||||||
{/* Day headers */}
|
<div className="flex flex-col flex-1 rounded-lg border border-border overflow-hidden min-h-0">
|
||||||
<div className="grid grid-cols-7 bg-muted/50">
|
{/* Day headers */}
|
||||||
{DAYS.map((day) => (
|
<div className="grid grid-cols-7 bg-muted/50 shrink-0">
|
||||||
<div key={day} className="px-2 py-2 text-center text-xs font-medium text-muted-foreground">
|
{DAYS.map((day) => (
|
||||||
{day}
|
<div key={day} className="px-2 py-2 text-center text-xs font-medium text-muted-foreground">
|
||||||
</div>
|
{day}
|
||||||
))}
|
</div>
|
||||||
</div>
|
))}
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* Day cells */}
|
{/* Day cells */}
|
||||||
<div className="grid grid-cols-7">
|
<div className="grid grid-cols-7 flex-1 overflow-y-auto">
|
||||||
{/* Empty cells for offset */}
|
{/* Empty cells for offset */}
|
||||||
{Array.from({ length: startDayOfWeek }).map((_, i) => (
|
{Array.from({ length: startDayOfWeek }).map((_, i) => (
|
||||||
<div key={`empty-${i}`} className="min-h-24 border-t border-r border-border bg-muted/20" />
|
<div key={`empty-${i}`} className="border-t border-r border-border bg-muted/20" />
|
||||||
))}
|
))}
|
||||||
|
|
||||||
{days.map((day) => {
|
{days.map((day) => {
|
||||||
const key = format(day, 'yyyy-MM-dd');
|
const key = format(day, 'yyyy-MM-dd');
|
||||||
const dayEpisodes = episodesByDate.get(key) || [];
|
const dayEpisodes = episodesByDate.get(key) || [];
|
||||||
const isToday = isSameDay(day, new Date());
|
const isToday = isSameDay(day, new Date());
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={key}
|
key={key}
|
||||||
className={`min-h-24 border-t border-r border-border p-1 ${
|
className={`border-t border-r border-border p-1.5 ${
|
||||||
isToday ? 'bg-primary/5' : ''
|
isToday ? 'bg-primary/5' : ''
|
||||||
}`}
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
className={`inline-flex h-6 w-6 items-center justify-center rounded-full text-xs ${
|
|
||||||
isToday
|
|
||||||
? 'bg-primary text-primary-foreground font-bold'
|
|
||||||
: 'text-muted-foreground'
|
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
{format(day, 'd')}
|
<span
|
||||||
</span>
|
className={`inline-flex h-6 w-6 items-center justify-center rounded-full text-xs mb-1 ${
|
||||||
<div className="mt-1 space-y-0.5">
|
isToday
|
||||||
{dayEpisodes.slice(0, 3).map((ep) => (
|
? 'bg-primary text-primary-foreground font-bold'
|
||||||
<Tooltip key={ep.id}>
|
: 'text-muted-foreground'
|
||||||
<TooltipTrigger asChild>
|
}`}
|
||||||
<div className="flex items-center gap-1 rounded bg-accent/50 px-1 py-0.5">
|
>
|
||||||
{ep.still_path && (
|
{format(day, 'd')}
|
||||||
<img
|
</span>
|
||||||
src={getTmdbPosterUrl(ep.still_path, 'w92')}
|
<div className="space-y-1">
|
||||||
alt=""
|
{dayEpisodes.slice(0, 4).map((ep) => (
|
||||||
className="h-4 w-6 rounded object-cover"
|
<EpisodeCalendarItem key={ep.id} episode={ep} />
|
||||||
/>
|
))}
|
||||||
)}
|
{dayEpisodes.length > 4 && (
|
||||||
<span className="text-[10px] truncate">
|
<span className="text-[10px] text-muted-foreground pl-1">
|
||||||
S{ep.season_id} E{ep.episode_number}
|
+{dayEpisodes.length - 4} more
|
||||||
</span>
|
</span>
|
||||||
</div>
|
)}
|
||||||
</TooltipTrigger>
|
</div>
|
||||||
<TooltipContent>
|
|
||||||
<p className="text-xs font-medium">{ep.name}</p>
|
|
||||||
<p className="text-xs text-muted-foreground">
|
|
||||||
Episode {ep.episode_number}
|
|
||||||
</p>
|
|
||||||
</TooltipContent>
|
|
||||||
</Tooltip>
|
|
||||||
))}
|
|
||||||
{dayEpisodes.length > 3 && (
|
|
||||||
<span className="text-[10px] text-muted-foreground pl-1">
|
|
||||||
+{dayEpisodes.length - 3} more
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
);
|
||||||
);
|
})}
|
||||||
})}
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</TooltipProvider>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function EpisodeCalendarItem({ episode }: { episode: Episode }) {
|
||||||
|
type EpisodeWithEntry = Episode & {
|
||||||
|
entry?: {
|
||||||
|
id: number;
|
||||||
|
title?: string;
|
||||||
|
poster_path?: string | null;
|
||||||
|
medias?: unknown[];
|
||||||
|
isInLibrary?: boolean;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
const ep = episode as EpisodeWithEntry;
|
||||||
|
const entry = ep.entry;
|
||||||
|
const entryId = entry?.id;
|
||||||
|
const entryTitle = entry?.title ?? '';
|
||||||
|
const seasonId = episode.season_id;
|
||||||
|
|
||||||
|
const posterSrc = episode.still_path
|
||||||
|
? getTmdbPosterUrl(episode.still_path, 'w92')
|
||||||
|
: entry
|
||||||
|
? getPosterUrl({ ...(entry as Parameters<typeof getPosterUrl>[0]), isInLibrary: false })
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
const seasonLabel = `S${String(seasonId).padStart(2, '0')}`;
|
||||||
|
const episodeLabel = `E${String(episode.episode_number).padStart(2, '0')}`;
|
||||||
|
|
||||||
|
const content = (
|
||||||
|
<div className="flex items-center gap-1.5 rounded bg-accent/60 hover:bg-accent px-1 py-1 transition-colors cursor-pointer">
|
||||||
|
{posterSrc && (
|
||||||
|
<img
|
||||||
|
src={posterSrc}
|
||||||
|
alt=""
|
||||||
|
className="h-10 w-7 rounded object-cover shrink-0"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<div className="min-w-0">
|
||||||
|
<p className="text-[10px] font-medium truncate leading-tight">
|
||||||
|
{entryTitle}
|
||||||
|
</p>
|
||||||
|
<p className="text-[9px] text-muted-foreground tabular-nums">
|
||||||
|
{seasonLabel} {episodeLabel}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger asChild>
|
||||||
|
{entryId ? (
|
||||||
|
<Link
|
||||||
|
to={`/entry/${entryId}/season/${seasonId}/episode/${episode.id}`}
|
||||||
|
className="block"
|
||||||
|
>
|
||||||
|
{content}
|
||||||
|
</Link>
|
||||||
|
) : (
|
||||||
|
<div>{content}</div>
|
||||||
|
)}
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent side="right" className="max-w-50">
|
||||||
|
<p className="text-xs font-semibold">{entryTitle}</p>
|
||||||
|
{episode.name && (
|
||||||
|
<p className="text-xs">{episode.name}</p>
|
||||||
|
)}
|
||||||
|
<p className="text-xs text-muted-foreground">
|
||||||
|
{seasonLabel} {episodeLabel}
|
||||||
|
</p>
|
||||||
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,12 +1,14 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams, Link } from 'react-router-dom';
|
||||||
import { useEntry, useEntrySeasons, useRefreshEntry } from '@/hooks/useEntries';
|
import { useEntry, useEntrySeasons, useRefreshEntry } from '@/hooks/useEntries';
|
||||||
import { useEntrySeenByEntry, useDeleteEntrySeen } from '@/hooks/useEntrySeen';
|
import { useEntrySeenByEntry, useDeleteEntrySeen } from '@/hooks/useEntrySeen';
|
||||||
|
import { useCollections } from '@/hooks/useCollections';
|
||||||
import { useLibraryStore } from '@/stores/useLibraryStore';
|
import { useLibraryStore } from '@/stores/useLibraryStore';
|
||||||
import { Skeleton } from '@/components/ui/skeleton';
|
import { Skeleton } from '@/components/ui/skeleton';
|
||||||
import { Badge } from '@/components/ui/badge';
|
import { Badge } from '@/components/ui/badge';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Separator } from '@/components/ui/separator';
|
import { Separator } from '@/components/ui/separator';
|
||||||
|
import { ScrollArea, ScrollBar } from '@/components/ui/scroll-area';
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
@@ -33,20 +35,21 @@ import {
|
|||||||
import { CastList } from '@/components/entries/CastList';
|
import { CastList } from '@/components/entries/CastList';
|
||||||
import { SeasonsContainer } from '@/components/entries/SeasonsContainer';
|
import { SeasonsContainer } from '@/components/entries/SeasonsContainer';
|
||||||
import { EpisodeWatchHistory } from '@/components/entries/EpisodeWatchHistory';
|
import { EpisodeWatchHistory } from '@/components/entries/EpisodeWatchHistory';
|
||||||
import { CollectionsGrid } from '@/components/collections/CollectionsGrid';
|
|
||||||
import { EntrySettingsDialog } from '@/components/dialogs/EntrySettingsDialog';
|
import { EntrySettingsDialog } from '@/components/dialogs/EntrySettingsDialog';
|
||||||
import { EntrySeenDialog } from '@/components/dialogs/EntrySeenDialog';
|
import { EntrySeenDialog } from '@/components/dialogs/EntrySeenDialog';
|
||||||
import { EntryMediaDialog } from '@/components/dialogs/EntryMediaDialog';
|
import { EntryMediaDialog } from '@/components/dialogs/EntryMediaDialog';
|
||||||
import { AddEntryToCollectionDialog } from '@/components/dialogs/AddEntryToCollectionDialog';
|
import { AddEntryToCollectionDialog } from '@/components/dialogs/AddEntryToCollectionDialog';
|
||||||
|
import { RatingDialog } from '@/components/dialogs/RatingDialog';
|
||||||
import {
|
import {
|
||||||
getPosterUrl,
|
getPosterUrl,
|
||||||
getBackdropUrl,
|
getBackdropUrl,
|
||||||
|
getCollectionBackdropUrl,
|
||||||
getYear,
|
getYear,
|
||||||
formatRuntime,
|
formatRuntime,
|
||||||
formatDate,
|
formatDate,
|
||||||
} from '@/lib/media-utils';
|
} from '@/lib/media-utils';
|
||||||
import { useUpdateEntry } from '@/hooks/useEntries';
|
import { useUpdateEntry } from '@/hooks/useEntries';
|
||||||
import type { Entry } from '@/types';
|
import type { Collection, Entry } from '@/types';
|
||||||
|
|
||||||
export function EntryDetailsPage() {
|
export function EntryDetailsPage() {
|
||||||
const { id } = useParams<{ id: string }>();
|
const { id } = useParams<{ id: string }>();
|
||||||
@@ -64,11 +67,11 @@ export function EntryDetailsPage() {
|
|||||||
? { ...libraryEntry, ...entry, isInLibrary: true }
|
? { ...libraryEntry, ...entry, isInLibrary: true }
|
||||||
: entry || libraryEntry;
|
: entry || libraryEntry;
|
||||||
|
|
||||||
// Dialog states
|
|
||||||
const [showSettings, setShowSettings] = useState(false);
|
const [showSettings, setShowSettings] = useState(false);
|
||||||
const [showSeenDialog, setShowSeenDialog] = useState(false);
|
const [showSeenDialog, setShowSeenDialog] = useState(false);
|
||||||
const [showMediaDialog, setShowMediaDialog] = useState(false);
|
const [showMediaDialog, setShowMediaDialog] = useState(false);
|
||||||
const [showCollectionDialog, setShowCollectionDialog] = useState(false);
|
const [showCollectionDialog, setShowCollectionDialog] = useState(false);
|
||||||
|
const [showRatingDialog, setShowRatingDialog] = useState(false);
|
||||||
|
|
||||||
if (isLoading || !displayEntry) {
|
if (isLoading || !displayEntry) {
|
||||||
return <EntryDetailsSkeleton />;
|
return <EntryDetailsSkeleton />;
|
||||||
@@ -86,37 +89,120 @@ export function EntryDetailsPage() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-8">
|
<div>
|
||||||
{/* Hero Section */}
|
{/* Backdrop banner */}
|
||||||
<div className="relative -mx-6 -mt-6 overflow-hidden">
|
<div className="relative -mx-6 -mt-6 h-52 overflow-hidden">
|
||||||
{backdrop && (
|
{backdrop ? (
|
||||||
<img
|
<img
|
||||||
src={backdrop}
|
src={backdrop}
|
||||||
alt=""
|
alt=""
|
||||||
className="h-72 w-full object-cover opacity-30 blur-sm"
|
className="h-full w-full object-cover opacity-25 blur-sm scale-105"
|
||||||
/>
|
/>
|
||||||
|
) : (
|
||||||
|
<div className="h-full w-full bg-linear-to-br from-primary/15 to-primary/5" />
|
||||||
)}
|
)}
|
||||||
<div className="absolute inset-0 bg-gradient-to-t from-background to-transparent" />
|
<div className="absolute inset-0 bg-linear-to-t from-background via-background/60 to-transparent" />
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="relative mx-auto flex max-w-5xl gap-6 px-6 pb-6 pt-4">
|
{/* Main content */}
|
||||||
{/* Poster */}
|
<div className="mx-auto max-w-4xl">
|
||||||
<div className="shrink-0">
|
{/* Two-column header: sticky poster | info */}
|
||||||
|
<div className="flex gap-8 -mt-24 relative items-start">
|
||||||
|
{/* LEFT: Sticky poster + actions */}
|
||||||
|
<div className="sticky top-20 w-44 shrink-0 space-y-3 self-start">
|
||||||
<img
|
<img
|
||||||
src={poster}
|
src={poster}
|
||||||
alt={e.title}
|
alt={e.title}
|
||||||
className="h-72 w-48 rounded-lg object-cover shadow-lg"
|
className="w-full aspect-2/3 rounded-xl object-cover shadow-2xl ring-1 ring-border/50"
|
||||||
/>
|
/>
|
||||||
|
<div className="flex flex-col gap-2">
|
||||||
|
<Button
|
||||||
|
variant={e.favorit ? 'default' : 'outline'}
|
||||||
|
size="sm"
|
||||||
|
className="w-full justify-start"
|
||||||
|
onClick={toggleFavorite}
|
||||||
|
>
|
||||||
|
<Heart className={`mr-2 h-4 w-4 ${e.favorit ? 'fill-current' : ''}`} />
|
||||||
|
{e.favorit ? 'Favorited' : 'Favorite'}
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
className="w-full justify-start"
|
||||||
|
onClick={() => setShowSeenDialog(true)}
|
||||||
|
>
|
||||||
|
<Eye className="mr-2 h-4 w-4" />
|
||||||
|
Mark Watched
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<DropdownMenu>
|
||||||
|
<DropdownMenuTrigger asChild>
|
||||||
|
<Button variant="ghost" size="sm" className="w-full justify-start">
|
||||||
|
<MoreHorizontal className="mr-2 h-4 w-4" />
|
||||||
|
More actions
|
||||||
|
</Button>
|
||||||
|
</DropdownMenuTrigger>
|
||||||
|
<DropdownMenuContent align="start" side="right" className="w-56">
|
||||||
|
<DropdownMenuItem onClick={() => setShowRatingDialog(true)}>
|
||||||
|
<Star className="mr-2 h-4 w-4" />
|
||||||
|
Rate this
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem
|
||||||
|
onClick={() =>
|
||||||
|
updateEntry.mutate({ id: e.id, data: { hidden: !e.hidden } })
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<EyeOff className="mr-2 h-4 w-4" />
|
||||||
|
{e.hidden ? 'Unhide' : 'Hide'}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem onClick={() => refreshEntry.mutate(e.id)}>
|
||||||
|
<RefreshCw className="mr-2 h-4 w-4" />
|
||||||
|
Refresh details
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem onClick={() => setShowCollectionDialog(true)}>
|
||||||
|
<FolderPlus className="mr-2 h-4 w-4" />
|
||||||
|
Add to collection
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem onClick={() => setShowMediaDialog(true)}>
|
||||||
|
<ImageIcon className="mr-2 h-4 w-4" />
|
||||||
|
Manage media
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem onClick={() => setShowSettings(true)}>
|
||||||
|
<Settings className="mr-2 h-4 w-4" />
|
||||||
|
Settings
|
||||||
|
</DropdownMenuItem>
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Info */}
|
{/* RIGHT: Entry info */}
|
||||||
<div className="flex flex-1 flex-col justify-end space-y-3">
|
<div className="flex-1 min-w-0 space-y-4">
|
||||||
<div className="flex items-center gap-3">
|
{/* Title + status + director */}
|
||||||
<h1 className="text-3xl font-bold">{e.title}</h1>
|
<div className="space-y-1">
|
||||||
{e.status && (
|
<div className="flex flex-wrap items-start gap-2">
|
||||||
<Badge variant="secondary">{e.status}</Badge>
|
<h1 className="text-3xl font-bold leading-tight">{e.title}</h1>
|
||||||
|
{e.status && (
|
||||||
|
<Badge variant="secondary" className="mt-1 shrink-0">
|
||||||
|
{e.status}
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{director && (
|
||||||
|
<p className="text-sm text-muted-foreground">
|
||||||
|
by{' '}
|
||||||
|
<Link
|
||||||
|
to={`/people/${director.people_id}`}
|
||||||
|
className="font-medium text-foreground hover:underline"
|
||||||
|
>
|
||||||
|
{director.people?.name}
|
||||||
|
</Link>
|
||||||
|
</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Meta */}
|
||||||
<div className="flex flex-wrap items-center gap-2 text-sm text-muted-foreground">
|
<div className="flex flex-wrap items-center gap-2 text-sm text-muted-foreground">
|
||||||
{e.release_date && (
|
{e.release_date && (
|
||||||
<TooltipProvider>
|
<TooltipProvider>
|
||||||
@@ -138,12 +224,6 @@ export function EntryDetailsPage() {
|
|||||||
<span>{formatRuntime(e.runtime)}</span>
|
<span>{formatRuntime(e.runtime)}</span>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{director && (
|
|
||||||
<>
|
|
||||||
<span>•</span>
|
|
||||||
<span>Dir. {director.people?.name}</span>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Genres */}
|
{/* Genres */}
|
||||||
@@ -158,145 +238,83 @@ export function EntryDetailsPage() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Ratings */}
|
{/* Ratings */}
|
||||||
<div className="flex items-center gap-4">
|
<div className="flex flex-wrap items-center gap-2">
|
||||||
{e.entryRatings?.user_rating != null &&
|
{e.entryRatings?.imdb_rating != null &&
|
||||||
e.entryRatings.user_rating > 0 && (
|
e.entryRatings.imdb_rating > 0 && (
|
||||||
<div className="flex items-center gap-1">
|
<span className="inline-flex items-center gap-1 rounded-full bg-yellow-500/10 border border-yellow-500/20 px-3 py-1 text-sm text-yellow-600 dark:text-yellow-400 font-medium">
|
||||||
<Star className="h-4 w-4 fill-yellow-400 text-yellow-400" />
|
<span className="font-bold">IMDb:</span>
|
||||||
<span className="text-sm font-medium">
|
{e.entryRatings.imdb_rating}/10
|
||||||
{e.entryRatings.user_rating}/10
|
</span>
|
||||||
</span>
|
|
||||||
<span className="text-xs text-muted-foreground">You</span>
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
{e.entryRatings?.tmdb_rating != null &&
|
{e.entryRatings?.tmdb_rating != null &&
|
||||||
e.entryRatings.tmdb_rating > 0 && (
|
e.entryRatings.tmdb_rating > 0 && (
|
||||||
<div className="flex items-center gap-1">
|
<span className="inline-flex items-center gap-1 rounded-full bg-blue-500/10 border border-blue-500/20 px-3 py-1 text-sm text-blue-600 dark:text-blue-400 font-medium">
|
||||||
<span className="text-sm font-medium">
|
<span className="font-bold">TMDB:</span>
|
||||||
{e.entryRatings.tmdb_rating.toFixed(1)}
|
{e.entryRatings.tmdb_rating.toFixed(1)}/10
|
||||||
</span>
|
</span>
|
||||||
<span className="text-xs text-muted-foreground">TMDB</span>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{e.entryRatings?.imdb_rating != null &&
|
|
||||||
e.entryRatings.imdb_rating > 0 && (
|
|
||||||
<div className="flex items-center gap-1">
|
|
||||||
<span className="text-sm font-medium">
|
|
||||||
{e.entryRatings.imdb_rating}
|
|
||||||
</span>
|
|
||||||
<span className="text-xs text-muted-foreground">IMDb</span>
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
|
{e.entryRatings?.user_rating != null &&
|
||||||
|
e.entryRatings.user_rating > 0 ? (
|
||||||
|
<button
|
||||||
|
className="inline-flex items-center gap-1 rounded-full bg-accent border border-border px-3 py-1 text-sm font-medium hover:bg-accent/80 transition-colors"
|
||||||
|
onClick={() => setShowRatingDialog(true)}
|
||||||
|
title="Click to change rating"
|
||||||
|
>
|
||||||
|
<Star className="h-3.5 w-3.5 fill-yellow-400 text-yellow-400" />
|
||||||
|
<span className="font-bold">You:</span>
|
||||||
|
{e.entryRatings.user_rating}/10
|
||||||
|
</button>
|
||||||
|
) : (
|
||||||
|
<button
|
||||||
|
className="inline-flex items-center gap-1.5 rounded-full border border-dashed border-border px-3 py-1 text-sm text-muted-foreground hover:border-border hover:text-foreground transition-colors"
|
||||||
|
onClick={() => setShowRatingDialog(true)}
|
||||||
|
>
|
||||||
|
<Star className="h-3.5 w-3.5" />
|
||||||
|
Rate
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Actions */}
|
{/* Storyline */}
|
||||||
<div className="flex items-center gap-2 pt-2">
|
{e.storyline && (
|
||||||
<Button
|
<p className="text-sm text-muted-foreground leading-relaxed max-w-prose">
|
||||||
variant={e.favorit ? 'default' : 'outline'}
|
{e.storyline}
|
||||||
size="sm"
|
</p>
|
||||||
onClick={toggleFavorite}
|
)}
|
||||||
>
|
|
||||||
<Heart
|
|
||||||
className={`mr-1 h-4 w-4 ${
|
|
||||||
e.favorit ? 'fill-current' : ''
|
|
||||||
}`}
|
|
||||||
/>
|
|
||||||
{e.favorit ? 'Favorited' : 'Favorite'}
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
variant="outline"
|
|
||||||
size="sm"
|
|
||||||
onClick={() => setShowSeenDialog(true)}
|
|
||||||
>
|
|
||||||
<Eye className="mr-1 h-4 w-4" />
|
|
||||||
Mark Watched
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<DropdownMenu>
|
|
||||||
<DropdownMenuTrigger asChild>
|
|
||||||
<Button variant="outline" size="icon" className="h-8 w-8">
|
|
||||||
<MoreHorizontal className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
</DropdownMenuTrigger>
|
|
||||||
<DropdownMenuContent align="end">
|
|
||||||
<DropdownMenuItem
|
|
||||||
onClick={() =>
|
|
||||||
updateEntry.mutate({
|
|
||||||
id: e.id,
|
|
||||||
data: { hidden: !e.hidden },
|
|
||||||
})
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<EyeOff className="mr-2 h-4 w-4" />
|
|
||||||
{e.hidden ? 'Unhide' : 'Hide'}
|
|
||||||
</DropdownMenuItem>
|
|
||||||
<DropdownMenuItem
|
|
||||||
onClick={() => refreshEntry.mutate(e.id)}
|
|
||||||
>
|
|
||||||
<RefreshCw className="mr-2 h-4 w-4" />
|
|
||||||
Refresh Details
|
|
||||||
</DropdownMenuItem>
|
|
||||||
<DropdownMenuItem
|
|
||||||
onClick={() => setShowCollectionDialog(true)}
|
|
||||||
>
|
|
||||||
<FolderPlus className="mr-2 h-4 w-4" />
|
|
||||||
Add to Collection
|
|
||||||
</DropdownMenuItem>
|
|
||||||
<DropdownMenuItem
|
|
||||||
onClick={() => setShowMediaDialog(true)}
|
|
||||||
>
|
|
||||||
<ImageIcon className="mr-2 h-4 w-4" />
|
|
||||||
Media
|
|
||||||
</DropdownMenuItem>
|
|
||||||
<DropdownMenuItem
|
|
||||||
onClick={() => setShowSettings(true)}
|
|
||||||
>
|
|
||||||
<Settings className="mr-2 h-4 w-4" />
|
|
||||||
Settings
|
|
||||||
</DropdownMenuItem>
|
|
||||||
</DropdownMenuContent>
|
|
||||||
</DropdownMenu>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Storyline */}
|
{/* Sections */}
|
||||||
{e.storyline && (
|
<div className="mt-10 space-y-8">
|
||||||
<div className="space-y-2">
|
{e.credits && e.credits.length > 0 && (
|
||||||
<h3 className="text-lg font-semibold">Overview</h3>
|
<>
|
||||||
<p className="text-sm text-muted-foreground leading-relaxed">
|
<Separator />
|
||||||
{e.storyline}
|
<CastList credits={e.credits} />
|
||||||
</p>
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<EntryCollectionsSection entryId={e.id} />
|
||||||
|
|
||||||
|
{e.is_tvseries && seasons && seasons.length > 0 && (
|
||||||
|
<>
|
||||||
|
<Separator />
|
||||||
|
<SeasonsContainer seasons={seasons} entryId={e.id} />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{watchHistory.length > 0 && (
|
||||||
|
<>
|
||||||
|
<Separator />
|
||||||
|
<EpisodeWatchHistory
|
||||||
|
watchHistory={watchHistory}
|
||||||
|
onDelete={(seenId) =>
|
||||||
|
deleteEntrySeen.mutate({ id: seenId, entryId: e.id })
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
</div>
|
||||||
|
|
||||||
<Separator />
|
|
||||||
|
|
||||||
{/* Cast */}
|
|
||||||
{e.credits && e.credits.length > 0 && <CastList credits={e.credits} />}
|
|
||||||
|
|
||||||
{/* Seasons (TV only) */}
|
|
||||||
{e.is_tvseries && seasons && seasons.length > 0 && (
|
|
||||||
<>
|
|
||||||
<Separator />
|
|
||||||
<SeasonsContainer seasons={seasons} entryId={e.id} />
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Watch History */}
|
|
||||||
{watchHistory.length > 0 && (
|
|
||||||
<>
|
|
||||||
<Separator />
|
|
||||||
<EpisodeWatchHistory
|
|
||||||
watchHistory={watchHistory}
|
|
||||||
onDelete={(seenId) =>
|
|
||||||
deleteEntrySeen.mutate({ id: seenId, entryId: e.id })
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Dialogs */}
|
{/* Dialogs */}
|
||||||
{showSettings && (
|
{showSettings && (
|
||||||
@@ -330,22 +348,81 @@ export function EntryDetailsPage() {
|
|||||||
entryId={e.id}
|
entryId={e.id}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{showRatingDialog && (
|
||||||
|
<RatingDialog
|
||||||
|
open={showRatingDialog}
|
||||||
|
onOpenChange={setShowRatingDialog}
|
||||||
|
entry={e}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ---------- Collections section ---------- */
|
||||||
|
function EntryCollectionsSection({ entryId }: { entryId: number }) {
|
||||||
|
const { data: allCollections = [], isLoading } = useCollections();
|
||||||
|
|
||||||
|
const collections = allCollections.filter((col: Collection) =>
|
||||||
|
col.entries?.some((e: Entry) => e.id === entryId)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isLoading || collections.length === 0) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Separator />
|
||||||
|
<div className="space-y-3">
|
||||||
|
<h3 className="text-lg font-semibold">In Collections</h3>
|
||||||
|
<ScrollArea className="w-full">
|
||||||
|
<div className="flex gap-4 pb-4">
|
||||||
|
{collections.map((col: Collection) => (
|
||||||
|
<Link
|
||||||
|
key={col.id}
|
||||||
|
to={`/collections/${col.id}`}
|
||||||
|
className="group shrink-0 w-56 overflow-hidden rounded-lg relative block"
|
||||||
|
>
|
||||||
|
<div className="aspect-video w-full overflow-hidden bg-muted rounded-lg">
|
||||||
|
<img
|
||||||
|
src={getCollectionBackdropUrl(col)}
|
||||||
|
alt={col.name}
|
||||||
|
className="h-full w-full object-cover transition-transform group-hover:scale-105"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="absolute inset-0 bg-linear-to-t from-black/70 via-black/20 to-transparent rounded-lg" />
|
||||||
|
<div className="absolute bottom-0 left-0 right-0 p-3">
|
||||||
|
<p className="text-sm font-medium text-white line-clamp-2 leading-tight">
|
||||||
|
{col.name}
|
||||||
|
</p>
|
||||||
|
{col.entries && (
|
||||||
|
<p className="text-xs text-white/70 mt-0.5">
|
||||||
|
{col.entries.length} {col.entries.length === 1 ? 'title' : 'titles'}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</Link>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<ScrollBar orientation="horizontal" />
|
||||||
|
</ScrollArea>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function EntryDetailsSkeleton() {
|
function EntryDetailsSkeleton() {
|
||||||
return (
|
return (
|
||||||
<div className="space-y-8">
|
<div>
|
||||||
<div className="flex gap-6">
|
<div className="h-52 -mx-6 -mt-6 bg-muted animate-pulse" />
|
||||||
<Skeleton className="h-72 w-48 shrink-0 rounded-lg" />
|
<div className="max-w-4xl mx-auto flex gap-8 -mt-24">
|
||||||
<div className="flex-1 space-y-4">
|
<Skeleton className="h-64 w-44 shrink-0 rounded-xl" />
|
||||||
|
<div className="flex-1 space-y-4 pt-24">
|
||||||
<Skeleton className="h-8 w-64" />
|
<Skeleton className="h-8 w-64" />
|
||||||
<Skeleton className="h-4 w-40" />
|
<Skeleton className="h-4 w-32" />
|
||||||
<Skeleton className="h-4 w-80" />
|
<Skeleton className="h-4 w-80" />
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<Skeleton className="h-8 w-24" />
|
<Skeleton className="h-6 w-16" />
|
||||||
<Skeleton className="h-8 w-32" />
|
<Skeleton className="h-6 w-12" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ export function PeoplePage() {
|
|||||||
ref={index === people.length - 1 ? lastRef : undefined}
|
ref={index === people.length - 1 ? lastRef : undefined}
|
||||||
>
|
>
|
||||||
<Link
|
<Link
|
||||||
to={`/people/${person.id}`}
|
to={`/people/tmdb/${person.id}`}
|
||||||
className="group flex flex-col items-center gap-2 text-center"
|
className="group flex flex-col items-center gap-2 text-center"
|
||||||
>
|
>
|
||||||
<Avatar className="h-24 w-24 transition-transform group-hover:scale-105">
|
<Avatar className="h-24 w-24 transition-transform group-hover:scale-105">
|
||||||
|
|||||||
@@ -1,18 +1,24 @@
|
|||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { usePerson } from '@/hooks/usePeople';
|
import { usePerson, usePersonTmdbFilmography } from '@/hooks/usePeople';
|
||||||
import { useQuery } from '@tanstack/react-query';
|
import { useLibrary } from '@/hooks/useEntries';
|
||||||
import { peopleApi } from '@/api/people';
|
import { useLibraryStore } from '@/stores/useLibraryStore';
|
||||||
import { Skeleton } from '@/components/ui/skeleton';
|
import { Skeleton } from '@/components/ui/skeleton';
|
||||||
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
|
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
|
||||||
import { Separator } from '@/components/ui/separator';
|
import { Separator } from '@/components/ui/separator';
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
import { Badge } from '@/components/ui/badge';
|
||||||
import { EntryCard } from '@/components/entries/EntryCard';
|
import { EntryCard } from '@/components/entries/EntryCard';
|
||||||
import { getProfileUrl, formatDate } from '@/lib/media-utils';
|
import { getProfileUrl, formatDate } from '@/lib/media-utils';
|
||||||
|
import { getTmdbImageUrl } from '@/lib/api';
|
||||||
|
import type { TmdbFilmographyItem } from '@/api/people';
|
||||||
|
|
||||||
export function PersonDetailsPage() {
|
export function PersonDetailsPage() {
|
||||||
const { id } = useParams<{ id: string }>();
|
const { id } = useParams<{ id: string }>();
|
||||||
const personId = parseInt(id!, 10);
|
const personId = parseInt(id!, 10);
|
||||||
const { data: person, isLoading } = usePerson(personId);
|
const { data: person, isLoading } = usePerson(personId);
|
||||||
|
const { data: tmdbFilmography, isLoading: tmdbLoading } = usePersonTmdbFilmography(personId);
|
||||||
|
useLibrary();
|
||||||
|
const libraryMap = useLibraryStore((s) => s.entries);
|
||||||
|
const libraryLoaded = useLibraryStore((s) => s.isLoaded);
|
||||||
|
|
||||||
if (isLoading || !person) {
|
if (isLoading || !person) {
|
||||||
return (
|
return (
|
||||||
@@ -31,47 +37,21 @@ export function PersonDetailsPage() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-8">
|
<div className="space-y-8">
|
||||||
{/* Profile header */}
|
|
||||||
<div className="flex gap-8">
|
<div className="flex gap-8">
|
||||||
<Avatar className="h-48 w-48 shrink-0">
|
<Avatar className="h-48 w-48 shrink-0">
|
||||||
<AvatarImage
|
<AvatarImage src={getProfileUrl(person.profile_path)} alt={person.name} />
|
||||||
src={getProfileUrl(person.profile_path)}
|
|
||||||
alt={person.name}
|
|
||||||
/>
|
|
||||||
<AvatarFallback className="text-3xl">
|
<AvatarFallback className="text-3xl">
|
||||||
{person.name
|
{person.name.split(' ').map((n: string) => n[0]).join('')}
|
||||||
.split(' ')
|
|
||||||
.map((n: string) => n[0])
|
|
||||||
.join('')}
|
|
||||||
</AvatarFallback>
|
</AvatarFallback>
|
||||||
</Avatar>
|
</Avatar>
|
||||||
|
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
<h1 className="text-3xl font-bold">{person.name}</h1>
|
<h1 className="text-3xl font-bold">{person.name}</h1>
|
||||||
<div className="flex flex-wrap items-center gap-3 text-sm text-muted-foreground">
|
<div className="flex flex-wrap items-center gap-3 text-sm text-muted-foreground">
|
||||||
{person.known_for_department && (
|
{person.known_for_department && <span>{person.known_for_department}</span>}
|
||||||
<span>{person.known_for_department}</span>
|
{person.birthday && (<><span>•</span><span>Born: {formatDate(person.birthday)}</span></>)}
|
||||||
)}
|
{person.deathday && (<><span>•</span><span>Died: {formatDate(person.deathday)}</span></>)}
|
||||||
{person.birthday && (
|
{person.place_of_birth && (<><span>•</span><span>{person.place_of_birth}</span></>)}
|
||||||
<>
|
|
||||||
<span>•</span>
|
|
||||||
<span>Born: {formatDate(person.birthday)}</span>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{person.deathday && (
|
|
||||||
<>
|
|
||||||
<span>•</span>
|
|
||||||
<span>Died: {formatDate(person.deathday)}</span>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{person.place_of_birth && (
|
|
||||||
<>
|
|
||||||
<span>•</span>
|
|
||||||
<span>{person.place_of_birth}</span>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{person.biography && (
|
{person.biography && (
|
||||||
<p className="text-sm text-muted-foreground leading-relaxed max-w-2xl line-clamp-6">
|
<p className="text-sm text-muted-foreground leading-relaxed max-w-2xl line-clamp-6">
|
||||||
{person.biography}
|
{person.biography}
|
||||||
@@ -82,13 +62,118 @@ export function PersonDetailsPage() {
|
|||||||
|
|
||||||
<Separator />
|
<Separator />
|
||||||
|
|
||||||
{/* Filmography placeholder */}
|
<FilmographySection
|
||||||
|
libraryMap={libraryMap}
|
||||||
|
libraryLoaded={libraryLoaded}
|
||||||
|
tmdbFilmography={tmdbFilmography}
|
||||||
|
tmdbLoading={tmdbLoading}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface FilmographySectionProps {
|
||||||
|
libraryMap: Map<number, import('@/types').Entry>;
|
||||||
|
libraryLoaded: boolean;
|
||||||
|
tmdbFilmography?: { cast: TmdbFilmographyItem[]; crew: TmdbFilmographyItem[] };
|
||||||
|
tmdbLoading: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
function FilmographySection({ libraryMap, libraryLoaded, tmdbFilmography, tmdbLoading }: FilmographySectionProps) {
|
||||||
|
if (tmdbLoading || !libraryLoaded) {
|
||||||
|
return (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<h2 className="text-xl font-semibold">Filmography</h2>
|
<h2 className="text-xl font-semibold">Filmography</h2>
|
||||||
<p className="text-sm text-muted-foreground">
|
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5">
|
||||||
Filmography details will be loaded from credits associated with this person.
|
{Array.from({ length: 10 }).map((_, i) => (
|
||||||
</p>
|
<Skeleton key={i} className="aspect-2/3 rounded-lg" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const allTmdbCredits = [
|
||||||
|
...(tmdbFilmography?.cast ?? []),
|
||||||
|
...(tmdbFilmography?.crew?.filter((c) => c.job === 'Director' || c.department === 'Directing') ?? []),
|
||||||
|
];
|
||||||
|
const seenTmdbIds = new Set<number>();
|
||||||
|
const dedupedCredits = allTmdbCredits.filter((c) => {
|
||||||
|
if (seenTmdbIds.has(c.id)) return false;
|
||||||
|
seenTmdbIds.add(c.id);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
const tmdbIdToLibraryEntry = new Map<number, import('@/types').Entry>();
|
||||||
|
for (const entry of libraryMap.values()) {
|
||||||
|
if (entry.entryIds?.tmdb_id != null) {
|
||||||
|
tmdbIdToLibraryEntry.set(Number(entry.entryIds.tmdb_id), entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const libraryCredits = dedupedCredits.filter((c) => tmdbIdToLibraryEntry.has(c.id));
|
||||||
|
const otherCredits = dedupedCredits.filter((c) => !tmdbIdToLibraryEntry.has(c.id));
|
||||||
|
|
||||||
|
if (dedupedCredits.length === 0) {
|
||||||
|
return (
|
||||||
|
<div className="space-y-4">
|
||||||
|
<h2 className="text-xl font-semibold">Filmography</h2>
|
||||||
|
<p className="text-sm text-muted-foreground">No filmography found.</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="space-y-8">
|
||||||
|
<h2 className="text-xl font-semibold">Filmography</h2>
|
||||||
|
|
||||||
|
{libraryCredits.length > 0 && (
|
||||||
|
<div className="space-y-3">
|
||||||
|
<h3 className="text-sm font-medium text-muted-foreground uppercase tracking-wide">In Your Library</h3>
|
||||||
|
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5">
|
||||||
|
{libraryCredits.map((credit) => {
|
||||||
|
const entry = tmdbIdToLibraryEntry.get(credit.id)!;
|
||||||
|
return (
|
||||||
|
<div key={credit.id} className="space-y-1">
|
||||||
|
<EntryCard entry={entry} />
|
||||||
|
{credit.character && (
|
||||||
|
<p className="text-xs text-muted-foreground text-center line-clamp-1 px-1">{credit.character}</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{otherCredits.length > 0 && (
|
||||||
|
<div className="space-y-3">
|
||||||
|
<h3 className="text-sm font-medium text-muted-foreground uppercase tracking-wide">Not in Library</h3>
|
||||||
|
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5">
|
||||||
|
{otherCredits.map((credit) => {
|
||||||
|
const title = credit.title ?? credit.name ?? 'Unknown';
|
||||||
|
const posterSrc = credit.poster_path
|
||||||
|
? getTmdbImageUrl(credit.poster_path, 'w342')
|
||||||
|
: '/images/default-poster.png';
|
||||||
|
return (
|
||||||
|
<div key={credit.id} className="space-y-1">
|
||||||
|
<div className="relative aspect-2/3 overflow-hidden rounded-lg bg-muted">
|
||||||
|
<img src={posterSrc} alt={title} className="h-full w-full object-cover" />
|
||||||
|
<div className="absolute inset-0 bg-linear-to-t from-black/60 to-transparent" />
|
||||||
|
<p className="absolute bottom-0 left-0 right-0 p-2 text-xs font-medium text-white line-clamp-2">{title}</p>
|
||||||
|
<Badge variant="secondary" className="absolute top-1.5 right-1.5 text-[9px] px-1 py-0">
|
||||||
|
{credit.media_type === 'tv' ? 'TV' : 'Movie'}
|
||||||
|
</Badge>
|
||||||
|
</div>
|
||||||
|
{credit.character && (
|
||||||
|
<p className="text-xs text-muted-foreground text-center line-clamp-1 px-1">{credit.character}</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import { useEffect } from 'react';
|
||||||
|
import { useParams, useNavigate } from 'react-router-dom';
|
||||||
|
import { useFetchPersonByTmdbId } from '@/hooks/usePeople';
|
||||||
|
import { Skeleton } from '@/components/ui/skeleton';
|
||||||
|
|
||||||
|
export function PersonTmdbRedirectPage() {
|
||||||
|
const { tmdbId } = useParams<{ tmdbId: string }>();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const fetchPerson = useFetchPersonByTmdbId();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!tmdbId) return;
|
||||||
|
fetchPerson.mutate(parseInt(tmdbId, 10), {
|
||||||
|
onSuccess: (person) => {
|
||||||
|
navigate(`/people/${person.id}`, { replace: true });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [tmdbId]);
|
||||||
|
|
||||||
|
if (fetchPerson.isError) {
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col items-center justify-center gap-3 py-20">
|
||||||
|
<p className="text-lg font-semibold">Person not found</p>
|
||||||
|
<p className="text-sm text-muted-foreground">
|
||||||
|
Could not load person data from TMDB.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="space-y-6">
|
||||||
|
<div className="flex gap-6">
|
||||||
|
<Skeleton className="h-48 w-48 rounded-full" />
|
||||||
|
<div className="flex-1 space-y-3">
|
||||||
|
<Skeleton className="h-8 w-48" />
|
||||||
|
<Skeleton className="h-4 w-32" />
|
||||||
|
<Skeleton className="h-20 w-full" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -51,6 +51,11 @@ const PersonDetailsPage = lazy(() =>
|
|||||||
default: m.PersonDetailsPage,
|
default: m.PersonDetailsPage,
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
|
const PersonTmdbRedirectPage = lazy(() =>
|
||||||
|
import('@/pages/PersonTmdbRedirectPage').then((m) => ({
|
||||||
|
default: m.PersonTmdbRedirectPage,
|
||||||
|
}))
|
||||||
|
);
|
||||||
const SettingsPage = lazy(() =>
|
const SettingsPage = lazy(() =>
|
||||||
import('@/pages/SettingsPage').then((m) => ({ default: m.SettingsPage }))
|
import('@/pages/SettingsPage').then((m) => ({ default: m.SettingsPage }))
|
||||||
);
|
);
|
||||||
@@ -168,6 +173,14 @@ export const router = createBrowserRouter([
|
|||||||
</SuspensePage>
|
</SuspensePage>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/people/tmdb/:tmdbId',
|
||||||
|
element: (
|
||||||
|
<SuspensePage>
|
||||||
|
<PersonTmdbRedirectPage />
|
||||||
|
</SuspensePage>
|
||||||
|
),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/people/:id',
|
path: '/people/:id',
|
||||||
element: (
|
element: (
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ export interface EntryIds {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface EntryRatings {
|
export interface EntryRatings {
|
||||||
|
id?: number;
|
||||||
user_rating: number | null;
|
user_rating: number | null;
|
||||||
tmdb_rating: number | null;
|
tmdb_rating: number | null;
|
||||||
imdb_rating: number | null;
|
imdb_rating: number | null;
|
||||||
@@ -40,6 +41,8 @@ export interface Entry {
|
|||||||
favorit: boolean;
|
favorit: boolean;
|
||||||
hidden: boolean;
|
hidden: boolean;
|
||||||
note: string | null;
|
note: string | null;
|
||||||
|
show_in_calendar?: boolean;
|
||||||
|
auto_sync?: boolean;
|
||||||
date_first_seen: string | null;
|
date_first_seen: string | null;
|
||||||
date_last_seen: string | null;
|
date_last_seen: string | null;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
@@ -95,6 +98,8 @@ export interface Episode {
|
|||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
episodeSeens?: EpisodeSeen[];
|
episodeSeens?: EpisodeSeen[];
|
||||||
guest_stars?: Credit[];
|
guest_stars?: Credit[];
|
||||||
|
entry?: Entry;
|
||||||
|
season?: Season;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EntrySeen {
|
export interface EntrySeen {
|
||||||
@@ -146,6 +151,7 @@ export interface People {
|
|||||||
profile_path: string | null;
|
profile_path: string | null;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
|
roles?: Credit[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Credit {
|
export interface Credit {
|
||||||
@@ -158,6 +164,7 @@ export interface Credit {
|
|||||||
job: string | null;
|
job: string | null;
|
||||||
order: number | null;
|
order: number | null;
|
||||||
people?: People;
|
people?: People;
|
||||||
|
entry?: Entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Genre {
|
export interface Genre {
|
||||||
|
|||||||
Reference in new issue
Block a user