feat(frontend): navigate non-library entries to TMDB preview page
- Add TmdbPreviewPage showing TMDB details without adding to library - Display backdrop, poster, title, tagline, genres, rating, storyline - Show season/episode count for TV series - Add "Add to Library" button that creates entry then redirects to details page - Show "Already in Library — View" if entry exists in DB - Add /entry/tmdb/:type/:tmdbId route in router.tsx - Add TmdbPreview type, entriesApi.previewTmdb(), and useTmdbPreview() hook - Update EntryCard to navigate to preview page instead of auto-adding Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
1 parent
25b645a16f
commit
02cdcf733d
18 files changed
+919
-174
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
import { api } from '@/lib/api';
|
import { api } from '@/lib/api';
|
||||||
import { normalizeEntry } from '@/lib/normalizers';
|
import { normalizeEntry } from '@/lib/normalizers';
|
||||||
import type { Entry } from '@/types';
|
import type { Entry, TmdbPreview } from '@/types';
|
||||||
|
|
||||||
export const entriesApi = {
|
export const entriesApi = {
|
||||||
getAll: () =>
|
getAll: () =>
|
||||||
@@ -44,6 +44,9 @@ export const entriesApi = {
|
|||||||
|
|
||||||
syncSeries: () => api.get('/entries/sync-series').then((r) => r.data),
|
syncSeries: () => api.get('/entries/sync-series').then((r) => r.data),
|
||||||
|
|
||||||
|
previewTmdb: (tmdbId: number, type: 'movie' | 'tv') =>
|
||||||
|
api.get<TmdbPreview>(`/entries/tmdb/preview/${type}/${tmdbId}`).then((r) => r.data),
|
||||||
|
|
||||||
uploadMedia: (id: number, formData: FormData) =>
|
uploadMedia: (id: number, formData: FormData) =>
|
||||||
api
|
api
|
||||||
.post(`/entries/${id}/media`, formData, {
|
.post(`/entries/${id}/media`, formData, {
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ export interface OrphanResult {
|
|||||||
stills: number;
|
stills: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface OrphanPeopleResult {
|
||||||
|
count: number;
|
||||||
|
}
|
||||||
|
|
||||||
export const maintenanceApi = {
|
export const maintenanceApi = {
|
||||||
scanOrphanFiles: () =>
|
scanOrphanFiles: () =>
|
||||||
api.get<OrphanResult>('/maintenance/orphan-files').then((r) => r.data),
|
api.get<OrphanResult>('/maintenance/orphan-files').then((r) => r.data),
|
||||||
@@ -19,4 +23,10 @@ export const maintenanceApi = {
|
|||||||
|
|
||||||
deleteOrphanMediaRecords: () =>
|
deleteOrphanMediaRecords: () =>
|
||||||
api.delete<OrphanResult>('/maintenance/orphan-media-records').then((r) => r.data),
|
api.delete<OrphanResult>('/maintenance/orphan-media-records').then((r) => r.data),
|
||||||
|
|
||||||
|
scanOrphanPeople: () =>
|
||||||
|
api.get<OrphanPeopleResult>('/maintenance/orphan-people').then((r) => r.data),
|
||||||
|
|
||||||
|
deleteOrphanPeople: () =>
|
||||||
|
api.delete<OrphanPeopleResult>('/maintenance/orphan-people').then((r) => r.data),
|
||||||
};
|
};
|
||||||
@@ -33,6 +33,12 @@ export const peopleApi = {
|
|||||||
getTmdbFilmography: (id: number) =>
|
getTmdbFilmography: (id: number) =>
|
||||||
api.get<TmdbFilmographyResponse>(`/people/${id}/tmdb-filmography`).then((r) => r.data),
|
api.get<TmdbFilmographyResponse>(`/people/${id}/tmdb-filmography`).then((r) => r.data),
|
||||||
|
|
||||||
fetchByTmdbId: (tmdb_id: number) =>
|
fetchByTmdbId: (tmdb_id: number, pinned = false) =>
|
||||||
api.post<People>('/people/fetch', { tmdb_id }).then((r) => r.data),
|
api.post<People>('/people/fetch', { tmdb_id, pinned }).then((r) => r.data),
|
||||||
|
|
||||||
|
update: (id: number, data: Partial<People>) =>
|
||||||
|
api.put<People>(`/people/${id}`, data).then((r) => r.data),
|
||||||
|
|
||||||
|
search: (query: string) =>
|
||||||
|
api.get<People[]>('/people/search', { params: { query } }).then((r) => r.data),
|
||||||
};
|
};
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { api } from '@/lib/api';
|
import { api } from '@/lib/api';
|
||||||
import type { Season } from '@/types';
|
import type { Season, Episode } from '@/types';
|
||||||
|
|
||||||
export const seasonsApi = {
|
export const seasonsApi = {
|
||||||
getAll: () => api.get<Season[]>('/seasons').then((r) => r.data),
|
getAll: () => api.get<Season[]>('/seasons').then((r) => r.data),
|
||||||
@@ -8,7 +8,7 @@ export const seasonsApi = {
|
|||||||
api.get<Season>(`/seasons/${id}`).then((r) => r.data),
|
api.get<Season>(`/seasons/${id}`).then((r) => r.data),
|
||||||
|
|
||||||
getEpisodes: (id: number) =>
|
getEpisodes: (id: number) =>
|
||||||
api.get(`/seasons/${id}/episodes`).then((r) => r.data),
|
api.get<Episode[]>(`/seasons/${id}/episodes`).then((r) => r.data),
|
||||||
|
|
||||||
create: (data: Partial<Season>) =>
|
create: (data: Partial<Season>) =>
|
||||||
api.post<Season>('/seasons', data).then((r) => r.data),
|
api.post<Season>('/seasons', data).then((r) => r.data),
|
||||||
|
|||||||
@@ -1,32 +1,56 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link, useNavigate } from 'react-router-dom';
|
||||||
import { Plus, Trash2, Star, Loader2, Calendar, Clock } from 'lucide-react';
|
import {
|
||||||
|
Plus, Star, Loader2, Heart, EyeOff, Trash2, MoreHorizontal, X,
|
||||||
|
Eye, History, FolderPlus, RefreshCw, ImageIcon, Settings,
|
||||||
|
} from 'lucide-react';
|
||||||
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 { Skeleton } from '@/components/ui/skeleton';
|
import { Skeleton } from '@/components/ui/skeleton';
|
||||||
import {
|
import {
|
||||||
Dialog,
|
DropdownMenu,
|
||||||
DialogContent,
|
DropdownMenuContent,
|
||||||
DialogHeader,
|
DropdownMenuItem,
|
||||||
DialogTitle,
|
DropdownMenuSeparator,
|
||||||
} from '@/components/ui/dialog';
|
DropdownMenuTrigger,
|
||||||
|
} from '@/components/ui/dropdown-menu';
|
||||||
import { getPosterUrl, getYear, formatRuntime } from '@/lib/media-utils';
|
import { getPosterUrl, getYear, formatRuntime } from '@/lib/media-utils';
|
||||||
import { useCreateEntry, useDeleteEntry } from '@/hooks/useEntries';
|
import { useCreateEntry, useDeleteEntry, useUpdateEntry, useRefreshEntry, useEntrySeasons } from '@/hooks/useEntries';
|
||||||
|
import { useEntrySeenByEntry, useDeleteEntrySeen } from '@/hooks/useEntrySeen';
|
||||||
import { useLibraryStore } from '@/stores/useLibraryStore';
|
import { useLibraryStore } from '@/stores/useLibraryStore';
|
||||||
import { ConfirmDialog } from '@/components/dialogs/ConfirmDialog';
|
import { ConfirmDialog } from '@/components/dialogs/ConfirmDialog';
|
||||||
|
import { EntrySeenDialog } from '@/components/dialogs/EntrySeenDialog';
|
||||||
|
import { RatingDialog } from '@/components/dialogs/RatingDialog';
|
||||||
|
import { MovieWatchHistoryDialog } from '@/components/dialogs/MovieWatchHistoryDialog';
|
||||||
|
import { AddEntryToCollectionDialog } from '@/components/dialogs/AddEntryToCollectionDialog';
|
||||||
|
import { EntryMediaDialog } from '@/components/dialogs/EntryMediaDialog';
|
||||||
|
import { EntrySettingsDialog } from '@/components/dialogs/EntrySettingsDialog';
|
||||||
import type { Entry, TmdbEntry } from '@/types';
|
import type { Entry, TmdbEntry } from '@/types';
|
||||||
|
|
||||||
interface EntryCardProps {
|
interface EntryCardProps {
|
||||||
entry?: Entry;
|
entry?: Entry;
|
||||||
tmdbEntry?: TmdbEntry;
|
tmdbEntry?: TmdbEntry;
|
||||||
showTypeBadge?: boolean;
|
showTypeBadge?: boolean;
|
||||||
|
/** When inside a collection, provide the collection ID to show "Remove from collection" action */
|
||||||
|
collectionId?: number;
|
||||||
|
/** Callback to remove entry from collection */
|
||||||
|
onRemoveFromCollection?: (entryId: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function EntryCard({ entry, tmdbEntry, showTypeBadge }: EntryCardProps) {
|
export function EntryCard({ entry, tmdbEntry, showTypeBadge, collectionId, onRemoveFromCollection }: EntryCardProps) {
|
||||||
const [showConfirm, setShowConfirm] = useState(false);
|
const [showConfirm, setShowConfirm] = useState(false);
|
||||||
const [showDetailDialog, setShowDetailDialog] = useState(false);
|
const [showRemoveCollectionConfirm, setShowRemoveCollectionConfirm] = useState(false);
|
||||||
|
const [showSeenDialog, setShowSeenDialog] = useState(false);
|
||||||
|
const [showRatingDialog, setShowRatingDialog] = useState(false);
|
||||||
|
const [showWatchHistoryDialog, setShowWatchHistoryDialog] = useState(false);
|
||||||
|
const [showCollectionDialog, setShowCollectionDialog] = useState(false);
|
||||||
|
const [showMediaDialog, setShowMediaDialog] = useState(false);
|
||||||
|
const [showSettingsDialog, setShowSettingsDialog] = useState(false);
|
||||||
|
const navigate = useNavigate();
|
||||||
const createEntry = useCreateEntry();
|
const createEntry = useCreateEntry();
|
||||||
const deleteEntry = useDeleteEntry();
|
const deleteEntry = useDeleteEntry();
|
||||||
|
const updateEntry = useUpdateEntry();
|
||||||
|
const refreshEntry = useRefreshEntry();
|
||||||
const libraryEntry = useLibraryStore((s) => {
|
const libraryEntry = useLibraryStore((s) => {
|
||||||
if (entry?.isInLibrary) return entry;
|
if (entry?.isInLibrary) return entry;
|
||||||
if (tmdbEntry) {
|
if (tmdbEntry) {
|
||||||
@@ -67,19 +91,18 @@ export function EntryCard({ entry, tmdbEntry, showTypeBadge }: EntryCardProps) {
|
|||||||
|
|
||||||
const entryLink = displayEntry
|
const entryLink = displayEntry
|
||||||
? `/entry/${displayEntry.id}`
|
? `/entry/${displayEntry.id}`
|
||||||
|
: tmdbEntry
|
||||||
|
? `/entry/tmdb/${isTv ? 'tv' : 'movie'}/${tmdbEntry.id}`
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const handleAdd = (e: React.MouseEvent) => {
|
const handleAdd = (e: React.MouseEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
if (!tmdbEntry) return;
|
if (!tmdbEntry) return;
|
||||||
createEntry.mutate({ tmdb_id: tmdbEntry.id, is_tvserie: isTv });
|
createEntry.mutate(
|
||||||
};
|
{ tmdb_id: tmdbEntry.id, is_tvserie: isTv },
|
||||||
|
{ onSuccess: (newEntry) => navigate(`/entry/${newEntry.id}`) }
|
||||||
const handleRemove = (e: React.MouseEvent) => {
|
);
|
||||||
e.preventDefault();
|
|
||||||
e.stopPropagation();
|
|
||||||
setShowConfirm(true);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const confirmRemove = () => {
|
const confirmRemove = () => {
|
||||||
@@ -90,10 +113,22 @@ export function EntryCard({ entry, tmdbEntry, showTypeBadge }: EntryCardProps) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const toggleFavorite = () => {
|
||||||
|
if (libraryEntry) {
|
||||||
|
updateEntry.mutate({ id: libraryEntry.id, data: { favorit: !libraryEntry.favorit } });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const toggleHidden = () => {
|
||||||
|
if (libraryEntry) {
|
||||||
|
updateEntry.mutate({ id: libraryEntry.id, data: { hidden: !libraryEntry.hidden } });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const card = (
|
const card = (
|
||||||
<div className="group relative overflow-hidden rounded-lg transition-all duration-300 hover:scale-[1.02] hover:shadow-xl animate-in fade-in zoom-in-95">
|
<div className="group relative overflow-hidden rounded-lg transition-all duration-300 hover:scale-[1.02] hover:shadow-xl animate-in fade-in zoom-in-95">
|
||||||
{/* Poster */}
|
{/* Poster */}
|
||||||
<div className="relative aspect-[2/3] w-full overflow-hidden rounded-lg bg-muted">
|
<div className="relative aspect-2/3 w-full overflow-hidden rounded-lg bg-muted">
|
||||||
<img
|
<img
|
||||||
src={posterUrl}
|
src={posterUrl}
|
||||||
alt={title}
|
alt={title}
|
||||||
@@ -108,9 +143,97 @@ export function EntryCard({ entry, tmdbEntry, showTypeBadge }: EntryCardProps) {
|
|||||||
</Badge>
|
</Badge>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Favorite indicator */}
|
{/* Favorite indicator – hidden on hover when actions button shows */}
|
||||||
{libraryEntry?.favorit && (
|
{libraryEntry?.favorit && (
|
||||||
<Star className="absolute right-2 top-2 h-4 w-4 fill-yellow-400 text-yellow-400" />
|
<Star className="absolute right-2 top-2 h-4 w-4 fill-yellow-400 text-yellow-400 transition-opacity group-hover:opacity-0" />
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Quick actions button – top right, shown on hover */}
|
||||||
|
{isInLibrary && (
|
||||||
|
<div className="absolute right-2 top-2 z-20 opacity-0 transition-opacity group-hover:opacity-100">
|
||||||
|
<DropdownMenu>
|
||||||
|
<DropdownMenuTrigger asChild>
|
||||||
|
<Button
|
||||||
|
variant="secondary"
|
||||||
|
size="icon"
|
||||||
|
className="h-7 w-7"
|
||||||
|
onClick={(e) => { e.preventDefault(); e.stopPropagation(); }}
|
||||||
|
>
|
||||||
|
<MoreHorizontal className="h-4 w-4" />
|
||||||
|
</Button>
|
||||||
|
</DropdownMenuTrigger>
|
||||||
|
<DropdownMenuContent align="end" className="w-52" onClick={(e) => e.stopPropagation()}>
|
||||||
|
{/* Watch & Rate */}
|
||||||
|
<DropdownMenuItem onClick={(e) => { e.stopPropagation(); setShowSeenDialog(true); }}>
|
||||||
|
<Eye className="mr-2 h-4 w-4" />
|
||||||
|
Mark as watched
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem onClick={(e) => { e.stopPropagation(); setShowRatingDialog(true); }}>
|
||||||
|
<Star className="mr-2 h-4 w-4" />
|
||||||
|
Rate this
|
||||||
|
</DropdownMenuItem>
|
||||||
|
{!isTv && (
|
||||||
|
<DropdownMenuItem onClick={(e) => { e.stopPropagation(); setShowWatchHistoryDialog(true); }}>
|
||||||
|
<History className="mr-2 h-4 w-4" />
|
||||||
|
Watch History
|
||||||
|
</DropdownMenuItem>
|
||||||
|
)}
|
||||||
|
<DropdownMenuSeparator />
|
||||||
|
{/* Organize */}
|
||||||
|
<DropdownMenuItem onClick={(e) => { e.stopPropagation(); toggleFavorite(); }}>
|
||||||
|
<Heart className={`mr-2 h-4 w-4 ${libraryEntry?.favorit ? 'fill-current' : ''}`} />
|
||||||
|
{libraryEntry?.favorit ? 'Unfavorite' : 'Favorite'}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem onClick={(e) => { e.stopPropagation(); setShowCollectionDialog(true); }}>
|
||||||
|
<FolderPlus className="mr-2 h-4 w-4" />
|
||||||
|
Add to collection
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem onClick={(e) => { e.stopPropagation(); toggleHidden(); }}>
|
||||||
|
<EyeOff className="mr-2 h-4 w-4" />
|
||||||
|
{libraryEntry?.hidden ? 'Unhide' : 'Hide'}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuSeparator />
|
||||||
|
{/* Manage */}
|
||||||
|
<DropdownMenuItem
|
||||||
|
onClick={(e) => { e.stopPropagation(); refreshEntry.mutate(libraryEntry!.id); }}
|
||||||
|
disabled={refreshEntry.isPending}
|
||||||
|
>
|
||||||
|
<RefreshCw className={`mr-2 h-4 w-4 ${refreshEntry.isPending ? 'animate-spin' : ''}`} />
|
||||||
|
{refreshEntry.isPending ? 'Refreshing...' : 'Refresh details'}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem onClick={(e) => { e.stopPropagation(); setShowMediaDialog(true); }}>
|
||||||
|
<ImageIcon className="mr-2 h-4 w-4" />
|
||||||
|
Manage media
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem onClick={(e) => { e.stopPropagation(); setShowSettingsDialog(true); }}>
|
||||||
|
<Settings className="mr-2 h-4 w-4" />
|
||||||
|
Settings
|
||||||
|
</DropdownMenuItem>
|
||||||
|
{/* Collection removal */}
|
||||||
|
{collectionId && onRemoveFromCollection && (
|
||||||
|
<>
|
||||||
|
<DropdownMenuSeparator />
|
||||||
|
<DropdownMenuItem
|
||||||
|
onClick={(e) => { e.stopPropagation(); setShowRemoveCollectionConfirm(true); }}
|
||||||
|
className="text-destructive focus:text-destructive"
|
||||||
|
>
|
||||||
|
<X className="mr-2 h-4 w-4" />
|
||||||
|
Remove from collection
|
||||||
|
</DropdownMenuItem>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
<DropdownMenuSeparator />
|
||||||
|
{/* Danger */}
|
||||||
|
<DropdownMenuItem
|
||||||
|
onClick={(e) => { e.stopPropagation(); setShowConfirm(true); }}
|
||||||
|
className="text-destructive focus:text-destructive"
|
||||||
|
>
|
||||||
|
<Trash2 className="mr-2 h-4 w-4" />
|
||||||
|
Delete entry
|
||||||
|
</DropdownMenuItem>
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Entry type pill */}
|
{/* Entry type pill */}
|
||||||
@@ -124,7 +247,7 @@ export function EntryCard({ entry, tmdbEntry, showTypeBadge }: EntryCardProps) {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Hover overlay */}
|
{/* Hover overlay */}
|
||||||
<div className="absolute inset-0 flex flex-col justify-end bg-gradient-to-t from-black/90 via-black/40 to-transparent opacity-0 transition-opacity duration-200 group-hover:opacity-100">
|
<div className="absolute inset-0 flex flex-col justify-end bg-linear-to-t from-black/90 via-black/40 to-transparent opacity-0 transition-opacity duration-200 group-hover:opacity-100">
|
||||||
<div className="p-3 space-y-1">
|
<div className="p-3 space-y-1">
|
||||||
<p className="text-sm font-semibold text-white line-clamp-2">
|
<p className="text-sm font-semibold text-white line-clamp-2">
|
||||||
{title}
|
{title}
|
||||||
@@ -140,24 +263,9 @@ export function EntryCard({ entry, tmdbEntry, showTypeBadge }: EntryCardProps) {
|
|||||||
{runtime && <span>{runtime}</span>}
|
{runtime && <span>{runtime}</span>}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Actions */}
|
{/* Add to Library – only for non-library entries */}
|
||||||
|
{!isInLibrary && tmdbEntry && (
|
||||||
<div className="pt-1">
|
<div className="pt-1">
|
||||||
{isInLibrary ? (
|
|
||||||
<Button
|
|
||||||
size="sm"
|
|
||||||
variant="destructive"
|
|
||||||
className="h-7 w-full text-xs"
|
|
||||||
onClick={handleRemove}
|
|
||||||
disabled={deleteEntry.isPending}
|
|
||||||
>
|
|
||||||
{deleteEntry.isPending ? (
|
|
||||||
<Loader2 className="mr-1 h-3 w-3 animate-spin" />
|
|
||||||
) : (
|
|
||||||
<Trash2 className="mr-1 h-3 w-3" />
|
|
||||||
)}
|
|
||||||
{deleteEntry.isPending ? 'Removing...' : 'Remove'}
|
|
||||||
</Button>
|
|
||||||
) : tmdbEntry ? (
|
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
className="h-7 w-full text-xs"
|
className="h-7 w-full text-xs"
|
||||||
@@ -171,8 +279,13 @@ export function EntryCard({ entry, tmdbEntry, showTypeBadge }: EntryCardProps) {
|
|||||||
)}
|
)}
|
||||||
{createEntry.isPending ? 'Adding...' : 'Add to Library'}
|
{createEntry.isPending ? 'Adding...' : 'Add to Library'}
|
||||||
</Button>
|
</Button>
|
||||||
) : null}
|
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -184,87 +297,119 @@ export function EntryCard({ entry, tmdbEntry, showTypeBadge }: EntryCardProps) {
|
|||||||
{entryLink ? (
|
{entryLink ? (
|
||||||
<Link to={entryLink}>{card}</Link>
|
<Link to={entryLink}>{card}</Link>
|
||||||
) : (
|
) : (
|
||||||
<div className="cursor-pointer" onClick={() => setShowDetailDialog(true)}>
|
card
|
||||||
{card}
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
<ConfirmDialog
|
<ConfirmDialog
|
||||||
open={showConfirm}
|
open={showConfirm}
|
||||||
onOpenChange={setShowConfirm}
|
onOpenChange={setShowConfirm}
|
||||||
title="Remove from Library"
|
title="Delete Entry"
|
||||||
description={`Are you sure you want to remove "${title}" from your library? This action cannot be undone.`}
|
description={`Are you sure you want to delete "${title}" from your library? This action cannot be undone.`}
|
||||||
confirmLabel="Remove"
|
confirmLabel="Delete"
|
||||||
onConfirm={confirmRemove}
|
onConfirm={confirmRemove}
|
||||||
variant="destructive"
|
variant="destructive"
|
||||||
/>
|
/>
|
||||||
{/* Details dialog for non-library entries */}
|
{collectionId && onRemoveFromCollection && (
|
||||||
{!entryLink && tmdbEntry && (
|
<ConfirmDialog
|
||||||
<Dialog open={showDetailDialog} onOpenChange={setShowDetailDialog}>
|
open={showRemoveCollectionConfirm}
|
||||||
<DialogContent className="sm:max-w-lg">
|
onOpenChange={setShowRemoveCollectionConfirm}
|
||||||
<DialogHeader>
|
title="Remove from Collection"
|
||||||
<DialogTitle>{title}</DialogTitle>
|
description={`Remove "${title}" from this collection?`}
|
||||||
</DialogHeader>
|
confirmLabel="Remove"
|
||||||
<div className="flex gap-4">
|
onConfirm={() => {
|
||||||
<img
|
if (libraryEntry) onRemoveFromCollection(libraryEntry.id);
|
||||||
src={posterUrl}
|
setShowRemoveCollectionConfirm(false);
|
||||||
alt={title}
|
|
||||||
className="h-48 w-32 shrink-0 rounded-lg object-cover"
|
|
||||||
/>
|
|
||||||
<div className="flex-1 space-y-2 min-w-0">
|
|
||||||
<div className="flex flex-wrap items-center gap-2 text-sm text-muted-foreground">
|
|
||||||
{year && (
|
|
||||||
<span className="flex items-center gap-1">
|
|
||||||
<Calendar className="h-3 w-3" />
|
|
||||||
{year}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
{isTv ? (
|
|
||||||
<Badge variant="secondary" className="text-[10px]">TV Series</Badge>
|
|
||||||
) : (
|
|
||||||
<Badge variant="secondary" className="text-[10px]">Movie</Badge>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
{tmdbEntry.vote_average > 0 && (
|
|
||||||
<div className="flex items-center gap-1 text-sm">
|
|
||||||
<Star className="h-3.5 w-3.5 fill-yellow-400 text-yellow-400" />
|
|
||||||
<span>{tmdbEntry.vote_average.toFixed(1)}/10</span>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{tmdbEntry.overview && (
|
|
||||||
<p className="text-sm text-muted-foreground line-clamp-6">
|
|
||||||
{tmdbEntry.overview}
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
<Button
|
|
||||||
size="sm"
|
|
||||||
className="mt-2"
|
|
||||||
onClick={(ev) => {
|
|
||||||
ev.stopPropagation();
|
|
||||||
handleAdd(ev);
|
|
||||||
setShowDetailDialog(false);
|
|
||||||
}}
|
}}
|
||||||
disabled={createEntry.isPending}
|
variant="destructive"
|
||||||
>
|
/>
|
||||||
{createEntry.isPending ? (
|
|
||||||
<Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />
|
|
||||||
) : (
|
|
||||||
<Plus className="mr-1.5 h-3.5 w-3.5" />
|
|
||||||
)}
|
)}
|
||||||
{createEntry.isPending ? 'Adding...' : 'Add to Library'}
|
{libraryEntry && showSeenDialog && (
|
||||||
</Button>
|
<LazyEntrySeenDialog
|
||||||
</div>
|
entry={libraryEntry}
|
||||||
</div>
|
open={showSeenDialog}
|
||||||
</DialogContent>
|
onOpenChange={setShowSeenDialog}
|
||||||
</Dialog>
|
/>
|
||||||
|
)}
|
||||||
|
{libraryEntry && showRatingDialog && (
|
||||||
|
<RatingDialog
|
||||||
|
open={showRatingDialog}
|
||||||
|
onOpenChange={setShowRatingDialog}
|
||||||
|
entry={libraryEntry}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{libraryEntry && showWatchHistoryDialog && (
|
||||||
|
<LazyMovieWatchHistoryDialog
|
||||||
|
entryId={libraryEntry.id}
|
||||||
|
open={showWatchHistoryDialog}
|
||||||
|
onOpenChange={setShowWatchHistoryDialog}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{libraryEntry && showCollectionDialog && (
|
||||||
|
<AddEntryToCollectionDialog
|
||||||
|
open={showCollectionDialog}
|
||||||
|
onOpenChange={setShowCollectionDialog}
|
||||||
|
entryId={libraryEntry.id}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{libraryEntry && showMediaDialog && (
|
||||||
|
<EntryMediaDialog
|
||||||
|
open={showMediaDialog}
|
||||||
|
onOpenChange={setShowMediaDialog}
|
||||||
|
entryId={libraryEntry.id}
|
||||||
|
medias={libraryEntry.medias || []}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{libraryEntry && showSettingsDialog && (
|
||||||
|
<EntrySettingsDialog
|
||||||
|
open={showSettingsDialog}
|
||||||
|
onOpenChange={setShowSettingsDialog}
|
||||||
|
entry={libraryEntry}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Lazy wrappers – only mount when dialog is open so hooks fetch on demand */
|
||||||
|
|
||||||
|
function LazyEntrySeenDialog({ entry, open, onOpenChange }: {
|
||||||
|
entry: Entry;
|
||||||
|
open: boolean;
|
||||||
|
onOpenChange: (open: boolean) => void;
|
||||||
|
}) {
|
||||||
|
const { data: seasons = [] } = useEntrySeasons(entry.id);
|
||||||
|
return (
|
||||||
|
<EntrySeenDialog
|
||||||
|
open={open}
|
||||||
|
onOpenChange={onOpenChange}
|
||||||
|
entry={entry}
|
||||||
|
seasons={seasons}
|
||||||
|
mode="add"
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function LazyMovieWatchHistoryDialog({ entryId, open, onOpenChange }: {
|
||||||
|
entryId: number;
|
||||||
|
open: boolean;
|
||||||
|
onOpenChange: (open: boolean) => void;
|
||||||
|
}) {
|
||||||
|
const { data: watchHistory = [] } = useEntrySeenByEntry(entryId);
|
||||||
|
const deleteEntrySeen = useDeleteEntrySeen();
|
||||||
|
return (
|
||||||
|
<MovieWatchHistoryDialog
|
||||||
|
open={open}
|
||||||
|
onOpenChange={onOpenChange}
|
||||||
|
entryId={entryId}
|
||||||
|
watchHistory={watchHistory}
|
||||||
|
onDelete={(seenId) => deleteEntrySeen.mutate({ id: seenId, entryId })}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function EntryCardSkeleton() {
|
export function EntryCardSkeleton() {
|
||||||
return (
|
return (
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<Skeleton className="aspect-[2/3] w-full rounded-lg" />
|
<Skeleton className="aspect-2/3 w-full rounded-lg" />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,8 @@ interface EntryLibraryGridProps {
|
|||||||
isLoading?: boolean;
|
isLoading?: boolean;
|
||||||
hasMore?: boolean;
|
hasMore?: boolean;
|
||||||
onLoadMore?: () => void;
|
onLoadMore?: () => void;
|
||||||
|
collectionId?: number;
|
||||||
|
onRemoveFromCollection?: (entryId: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function EntryLibraryGrid({
|
export function EntryLibraryGrid({
|
||||||
@@ -14,6 +16,8 @@ export function EntryLibraryGrid({
|
|||||||
isLoading,
|
isLoading,
|
||||||
hasMore,
|
hasMore,
|
||||||
onLoadMore,
|
onLoadMore,
|
||||||
|
collectionId,
|
||||||
|
onRemoveFromCollection,
|
||||||
}: EntryLibraryGridProps) {
|
}: EntryLibraryGridProps) {
|
||||||
const observerRef = useRef<IntersectionObserver | null>(null);
|
const observerRef = useRef<IntersectionObserver | null>(null);
|
||||||
|
|
||||||
@@ -62,7 +66,7 @@ export function EntryLibraryGrid({
|
|||||||
className="animate-card-enter"
|
className="animate-card-enter"
|
||||||
style={{ animationDelay: `${Math.min(index * 30, 300)}ms` }}
|
style={{ animationDelay: `${Math.min(index * 30, 300)}ms` }}
|
||||||
>
|
>
|
||||||
<EntryCard entry={entry} />
|
<EntryCard entry={entry} collectionId={collectionId} onRemoveFromCollection={onRemoveFromCollection} />
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
{isLoading &&
|
{isLoading &&
|
||||||
|
|||||||
@@ -69,3 +69,20 @@ export function useGetCollectionParts() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useRemoveEntryFromCollection() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: ({ collectionId, entryId }: { collectionId: number; entryId: number }) =>
|
||||||
|
collectionsApi.removeEntry(collectionId, entryId),
|
||||||
|
onSuccess: (_data, { collectionId }) => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: collectionKeys.detail(collectionId) });
|
||||||
|
queryClient.invalidateQueries({ queryKey: collectionKeys.all });
|
||||||
|
toast.success('Entry removed from collection');
|
||||||
|
},
|
||||||
|
onError: () => {
|
||||||
|
toast.error('Failed to remove entry from collection');
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ export const entryKeys = {
|
|||||||
all: ['entries'] as const,
|
all: ['entries'] as const,
|
||||||
detail: (id: number) => ['entries', id] as const,
|
detail: (id: number) => ['entries', id] as const,
|
||||||
seasons: (id: number) => ['entries', id, 'seasons'] as const,
|
seasons: (id: number) => ['entries', id, 'seasons'] as const,
|
||||||
|
tmdbPreview: (tmdbId: number, type: string) => ['entries', 'tmdb-preview', type, tmdbId] as const,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function useLibrary() {
|
export function useLibrary() {
|
||||||
@@ -153,3 +154,12 @@ export function useUploadMedia() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useTmdbPreview(tmdbId: number, type: 'movie' | 'tv') {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: entryKeys.tmdbPreview(tmdbId, type),
|
||||||
|
queryFn: () => entriesApi.previewTmdb(tmdbId, type),
|
||||||
|
enabled: !!tmdbId,
|
||||||
|
staleTime: 10 * 60 * 1000,
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { useQuery, useMutation } from '@tanstack/react-query';
|
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
|
import { toast } from 'sonner';
|
||||||
import { peopleApi } from '@/api/people';
|
import { peopleApi } from '@/api/people';
|
||||||
|
|
||||||
export const peopleKeys = {
|
export const peopleKeys = {
|
||||||
@@ -38,3 +39,27 @@ export function useFetchPersonByTmdbId() {
|
|||||||
mutationFn: (tmdb_id: number) => peopleApi.fetchByTmdbId(tmdb_id),
|
mutationFn: (tmdb_id: number) => peopleApi.fetchByTmdbId(tmdb_id),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useUpdatePerson() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: ({ id, data }: { id: number; data: Partial<import('@/types').People> }) =>
|
||||||
|
peopleApi.update(id, data),
|
||||||
|
onSuccess: (updatedPerson) => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: peopleKeys.detail(updatedPerson.id) });
|
||||||
|
toast.success('Person updated');
|
||||||
|
},
|
||||||
|
onError: () => {
|
||||||
|
toast.error('Failed to update person');
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useSearchLocalPeople(query: string) {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ['people', 'search', query],
|
||||||
|
queryFn: () => query === '*' ? peopleApi.getAll() : peopleApi.search(query),
|
||||||
|
enabled: query.length > 0,
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useState } from 'react';
|
import { useState, useMemo } from 'react';
|
||||||
import { useParams, useNavigate } from 'react-router-dom';
|
import { useParams, useNavigate } from 'react-router-dom';
|
||||||
import { useCollection, useDeleteCollection, useGetCollectionParts } from '@/hooks/useCollections';
|
import { useCollection, useDeleteCollection, useGetCollectionParts, useRemoveEntryFromCollection } from '@/hooks/useCollections';
|
||||||
import { EntryLibraryGrid } from '@/components/entries/EntryLibraryGrid';
|
import { EntryLibraryGrid } from '@/components/entries/EntryLibraryGrid';
|
||||||
import { getCollectionPosterUrl } from '@/lib/media-utils';
|
import { getCollectionPosterUrl } from '@/lib/media-utils';
|
||||||
import { getTmdbImageUrl } from '@/lib/api';
|
import { getTmdbImageUrl } from '@/lib/api';
|
||||||
@@ -12,10 +12,14 @@ import {
|
|||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from '@/components/ui/dropdown-menu';
|
} from '@/components/ui/dropdown-menu';
|
||||||
import { Star, MoreVertical, Pencil, Download, Trash2 } from 'lucide-react';
|
import { Star, MoreVertical, Pencil, Download, Trash2, ArrowUpDown, ArrowUp, ArrowDown } from 'lucide-react';
|
||||||
import { CollectionEditDialog } from '@/components/dialogs/CollectionEditDialog';
|
import { CollectionEditDialog } from '@/components/dialogs/CollectionEditDialog';
|
||||||
import { ConfirmDialog } from '@/components/dialogs/ConfirmDialog';
|
import { ConfirmDialog } from '@/components/dialogs/ConfirmDialog';
|
||||||
import { toast } from 'sonner';
|
import { toast } from 'sonner';
|
||||||
|
import type { Entry } from '@/types';
|
||||||
|
|
||||||
|
type CollectionSortField = 'order' | 'year' | 'title' | 'rating';
|
||||||
|
type SortDir = 'asc' | 'desc';
|
||||||
|
|
||||||
export function CollectionDetailsPage() {
|
export function CollectionDetailsPage() {
|
||||||
const { id } = useParams<{ id: string }>();
|
const { id } = useParams<{ id: string }>();
|
||||||
@@ -23,8 +27,11 @@ export function CollectionDetailsPage() {
|
|||||||
const { data: collection, isLoading, isError } = useCollection(Number(id));
|
const { data: collection, isLoading, isError } = useCollection(Number(id));
|
||||||
const [showEditDialog, setShowEditDialog] = useState(false);
|
const [showEditDialog, setShowEditDialog] = useState(false);
|
||||||
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
|
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
|
||||||
|
const [sortField, setSortField] = useState<CollectionSortField>('order');
|
||||||
|
const [sortDir, setSortDir] = useState<SortDir>('asc');
|
||||||
const deleteCollection = useDeleteCollection();
|
const deleteCollection = useDeleteCollection();
|
||||||
const getCollectionParts = useGetCollectionParts();
|
const getCollectionParts = useGetCollectionParts();
|
||||||
|
const removeEntryFromCollection = useRemoveEntryFromCollection();
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
@@ -33,7 +40,7 @@ export function CollectionDetailsPage() {
|
|||||||
<Skeleton className="h-8 w-64" />
|
<Skeleton className="h-8 w-64" />
|
||||||
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6">
|
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6">
|
||||||
{Array.from({ length: 6 }).map((_, i) => (
|
{Array.from({ length: 6 }).map((_, i) => (
|
||||||
<Skeleton key={i} className="aspect-[2/3] w-full rounded-lg" />
|
<Skeleton key={i} className="aspect-2/3 w-full rounded-lg" />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -55,6 +62,46 @@ export function CollectionDetailsPage() {
|
|||||||
isInLibrary: true,
|
isInLibrary: true,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
const sortedEntries = useMemo(() => {
|
||||||
|
const sorted = [...entries].sort((a, b) => {
|
||||||
|
let cmp = 0;
|
||||||
|
switch (sortField) {
|
||||||
|
case 'order': {
|
||||||
|
const oa = (a as Entry & { UserCollectionEntry?: { order: number } }).UserCollectionEntry?.order ?? 0;
|
||||||
|
const ob = (b as Entry & { UserCollectionEntry?: { order: number } }).UserCollectionEntry?.order ?? 0;
|
||||||
|
cmp = oa - ob;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'year': {
|
||||||
|
const ya = a.release_date ? new Date(a.release_date).getFullYear() : 0;
|
||||||
|
const yb = b.release_date ? new Date(b.release_date).getFullYear() : 0;
|
||||||
|
cmp = ya - yb;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'title':
|
||||||
|
cmp = (a.title || '').localeCompare(b.title || '');
|
||||||
|
break;
|
||||||
|
case 'rating': {
|
||||||
|
const ra = a.entryRatings?.user_rating || a.entryRatings?.tmdb_rating || 0;
|
||||||
|
const rb = b.entryRatings?.user_rating || b.entryRatings?.tmdb_rating || 0;
|
||||||
|
cmp = ra - rb;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sortDir === 'asc' ? cmp : -cmp;
|
||||||
|
});
|
||||||
|
return sorted;
|
||||||
|
}, [entries, sortField, sortDir]);
|
||||||
|
|
||||||
|
const handleSort = (field: CollectionSortField) => {
|
||||||
|
if (field === sortField) {
|
||||||
|
setSortDir((d) => (d === 'asc' ? 'desc' : 'asc'));
|
||||||
|
} else {
|
||||||
|
setSortField(field);
|
||||||
|
setSortDir(field === 'rating' ? 'desc' : 'asc');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleDelete = () => {
|
const handleDelete = () => {
|
||||||
deleteCollection.mutate(collection.id, {
|
deleteCollection.mutate(collection.id, {
|
||||||
onSuccess: () => navigate('/collections', { replace: true }),
|
onSuccess: () => navigate('/collections', { replace: true }),
|
||||||
@@ -78,7 +125,7 @@ export function CollectionDetailsPage() {
|
|||||||
) : (
|
) : (
|
||||||
<div className="h-48 w-full bg-muted sm:h-64" />
|
<div className="h-48 w-full bg-muted sm:h-64" />
|
||||||
)}
|
)}
|
||||||
<div className="absolute inset-0 bg-gradient-to-t from-background via-background/60 to-transparent" />
|
<div className="absolute inset-0 bg-linear-to-t from-background via-background/60 to-transparent" />
|
||||||
|
|
||||||
{/* Quick action menu - top right */}
|
{/* Quick action menu - top right */}
|
||||||
<div className="absolute top-3 right-3">
|
<div className="absolute top-3 right-3">
|
||||||
@@ -142,8 +189,38 @@ export function CollectionDetailsPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Sort toolbar */}
|
||||||
|
{entries.length > 1 && (
|
||||||
|
<div className="flex items-center gap-1.5">
|
||||||
|
<ArrowUpDown className="h-4 w-4 text-muted-foreground shrink-0" />
|
||||||
|
{(['order', 'year', 'title', 'rating'] as const).map((field) => (
|
||||||
|
<Button
|
||||||
|
key={field}
|
||||||
|
variant={sortField === field ? 'secondary' : 'ghost'}
|
||||||
|
size="sm"
|
||||||
|
className="h-7 text-xs capitalize gap-1"
|
||||||
|
onClick={() => handleSort(field)}
|
||||||
|
>
|
||||||
|
{field}
|
||||||
|
{sortField === field && (
|
||||||
|
sortDir === 'asc'
|
||||||
|
? <ArrowUp className="h-3 w-3" />
|
||||||
|
: <ArrowDown className="h-3 w-3" />
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Entries grid */}
|
{/* Entries grid */}
|
||||||
<EntryLibraryGrid entries={entries} isLoading={false} />
|
<EntryLibraryGrid
|
||||||
|
entries={sortedEntries}
|
||||||
|
isLoading={false}
|
||||||
|
collectionId={collection.id}
|
||||||
|
onRemoveFromCollection={(entryId) =>
|
||||||
|
removeEntryFromCollection.mutate({ collectionId: collection.id, entryId })
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
{/* Edit dialog */}
|
{/* Edit dialog */}
|
||||||
{showEditDialog && (
|
{showEditDialog && (
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import { useState, useMemo, useCallback, useEffect, useRef } from 'react';
|
|||||||
import { useSearchParams } from 'react-router-dom';
|
import { useSearchParams } from 'react-router-dom';
|
||||||
import { useLibrary } from '@/hooks/useEntries';
|
import { useLibrary } from '@/hooks/useEntries';
|
||||||
import { useLibraryEntries } from '@/stores/useLibraryStore';
|
import { useLibraryEntries } from '@/stores/useLibraryStore';
|
||||||
|
import { useLibraryFiltersStore, defaultFilters } from '@/stores/useLibraryFiltersStore';
|
||||||
|
import type { FilterTab, SortField, SortDir, Filters } from '@/stores/useLibraryFiltersStore';
|
||||||
import { EntryLibraryGrid } from '@/components/entries/EntryLibraryGrid';
|
import { EntryLibraryGrid } from '@/components/entries/EntryLibraryGrid';
|
||||||
import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
@@ -12,22 +14,6 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@
|
|||||||
import { Search, X, SlidersHorizontal, ArrowUpDown } from 'lucide-react';
|
import { Search, X, SlidersHorizontal, ArrowUpDown } from 'lucide-react';
|
||||||
import type { Entry } from '@/types';
|
import type { Entry } from '@/types';
|
||||||
|
|
||||||
type FilterTab = 'all' | 'movies' | 'tv' | 'favorites' | 'hidden';
|
|
||||||
type SortField = 'date_last_seen' | 'createdAt' | 'title' | 'release_date' | 'rating';
|
|
||||||
type SortDir = 'asc' | 'desc';
|
|
||||||
|
|
||||||
interface Filters {
|
|
||||||
genre: string;
|
|
||||||
tmdbRatingMin: string;
|
|
||||||
tmdbRatingMax: string;
|
|
||||||
userRatingMin: string;
|
|
||||||
userRatingMax: string;
|
|
||||||
yearMin: string;
|
|
||||||
yearMax: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const defaultFilters: Filters = { genre: '', tmdbRatingMin: '', tmdbRatingMax: '', userRatingMin: '', userRatingMax: '', yearMin: '', yearMax: '' };
|
|
||||||
|
|
||||||
const sortLabels: Record<SortField, string> = {
|
const sortLabels: Record<SortField, string> = {
|
||||||
date_last_seen: 'Last Watched',
|
date_last_seen: 'Last Watched',
|
||||||
createdAt: 'Date Added',
|
createdAt: 'Date Added',
|
||||||
@@ -66,13 +52,22 @@ const PAGE_SIZE = 28;
|
|||||||
export function LibraryPage() {
|
export function LibraryPage() {
|
||||||
const { isLoading } = useLibrary();
|
const { isLoading } = useLibrary();
|
||||||
const [searchParams, setSearchParams] = useSearchParams();
|
const [searchParams, setSearchParams] = useSearchParams();
|
||||||
const [activeTab, setActiveTab] = useState<FilterTab>('all');
|
|
||||||
const [search, setSearch] = useState('');
|
// Persistent filter state from store
|
||||||
const [debouncedSearch, setDebouncedSearch] = useState('');
|
const activeTab = useLibraryFiltersStore((s) => s.activeTab);
|
||||||
const [sortField, setSortField] = useState<SortField>('date_last_seen');
|
const setActiveTab = useLibraryFiltersStore((s) => s.setActiveTab);
|
||||||
const [sortDir, setSortDir] = useState<SortDir>('desc');
|
const search = useLibraryFiltersStore((s) => s.search);
|
||||||
const [filters, setFilters] = useState<Filters>(defaultFilters);
|
const setSearch = useLibraryFiltersStore((s) => s.setSearch);
|
||||||
const [debouncedFilters, setDebouncedFilters] = useState<Filters>(defaultFilters);
|
const sortField = useLibraryFiltersStore((s) => s.sortField);
|
||||||
|
const setSortField = useLibraryFiltersStore((s) => s.setSortField);
|
||||||
|
const sortDir = useLibraryFiltersStore((s) => s.sortDir);
|
||||||
|
const setSortDir = useLibraryFiltersStore((s) => s.setSortDir);
|
||||||
|
const filters = useLibraryFiltersStore((s) => s.filters);
|
||||||
|
const setFilters = useLibraryFiltersStore((s) => s.setFilters);
|
||||||
|
const clearFilters = useLibraryFiltersStore((s) => s.clearFilters);
|
||||||
|
|
||||||
|
const [debouncedSearch, setDebouncedSearch] = useState(search);
|
||||||
|
const [debouncedFilters, setDebouncedFilters] = useState<Filters>(filters);
|
||||||
const [visibleCount, setVisibleCount] = useState(PAGE_SIZE);
|
const [visibleCount, setVisibleCount] = useState(PAGE_SIZE);
|
||||||
const filtersInitialized = useRef(false);
|
const filtersInitialized = useRef(false);
|
||||||
|
|
||||||
@@ -92,7 +87,7 @@ export function LibraryPage() {
|
|||||||
// Clear URL params after applying
|
// Clear URL params after applying
|
||||||
setSearchParams({}, { replace: true });
|
setSearchParams({}, { replace: true });
|
||||||
}
|
}
|
||||||
}, [searchParams, setSearchParams]);
|
}, [searchParams, setSearchParams, setFilters]);
|
||||||
|
|
||||||
// Debounce search
|
// Debounce search
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -181,8 +176,6 @@ export function LibraryPage() {
|
|||||||
const hasMore = visibleCount < filteredEntries.length;
|
const hasMore = visibleCount < filteredEntries.length;
|
||||||
const loadMore = useCallback(() => setVisibleCount((c) => c + PAGE_SIZE), []);
|
const loadMore = useCallback(() => setVisibleCount((c) => c + PAGE_SIZE), []);
|
||||||
|
|
||||||
const clearFilters = useCallback(() => setFilters(defaultFilters), []);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-6 animate-page-enter">
|
<div className="space-y-6 animate-page-enter">
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
|
|||||||
@@ -1,26 +1,64 @@
|
|||||||
import { useState, useCallback, useRef, useEffect } from 'react';
|
import { useState, useCallback, useRef, useEffect, useMemo } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { usePopularPeople, useTmdbSearchPeople } from '@/hooks/useTmdb';
|
import { usePopularPeople, useTmdbSearchPeople } from '@/hooks/useTmdb';
|
||||||
|
import { useSearchLocalPeople } from '@/hooks/usePeople';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
|
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
|
||||||
import { Skeleton } from '@/components/ui/skeleton';
|
import { Skeleton } from '@/components/ui/skeleton';
|
||||||
import { Search } from 'lucide-react';
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { Switch } from '@/components/ui/switch';
|
||||||
|
import { Label } from '@/components/ui/label';
|
||||||
|
import { Search, Heart } from 'lucide-react';
|
||||||
import { getProfileUrl } from '@/lib/media-utils';
|
import { getProfileUrl } from '@/lib/media-utils';
|
||||||
|
|
||||||
|
type PeopleFilter = 'all' | 'favorite';
|
||||||
|
|
||||||
export function PeoplePage() {
|
export function PeoplePage() {
|
||||||
const [search, setSearch] = useState('');
|
const [search, setSearch] = useState('');
|
||||||
const isSearching = search.length > 0;
|
const [debouncedSearch, setDebouncedSearch] = useState('');
|
||||||
|
const [filter, setFilter] = useState<PeopleFilter>('all');
|
||||||
|
const [localOnly, setLocalOnly] = useState(false);
|
||||||
|
|
||||||
|
// Debounce search input
|
||||||
|
useEffect(() => {
|
||||||
|
const timer = setTimeout(() => setDebouncedSearch(search), 400);
|
||||||
|
return () => clearTimeout(timer);
|
||||||
|
}, [search]);
|
||||||
|
|
||||||
|
const isSearching = debouncedSearch.length > 0;
|
||||||
|
|
||||||
const popularQuery = usePopularPeople();
|
const popularQuery = usePopularPeople();
|
||||||
const searchQuery = useTmdbSearchPeople(search);
|
const tmdbSearchQuery = useTmdbSearchPeople(localOnly ? '' : debouncedSearch);
|
||||||
|
const { data: localSearchResults = [], isLoading: localSearchLoading } = useSearchLocalPeople(
|
||||||
|
localOnly ? debouncedSearch : ''
|
||||||
|
);
|
||||||
|
|
||||||
const activeQuery = isSearching ? searchQuery : popularQuery;
|
// For TMDB mode, use infinite scroll queries
|
||||||
const people = activeQuery.data?.pages.flatMap((p) => p.results) ?? [];
|
const activeQuery = isSearching && !localOnly ? tmdbSearchQuery : !localOnly ? popularQuery : null;
|
||||||
|
const tmdbPeople = activeQuery?.data?.pages.flatMap((p) => p.results) ?? [];
|
||||||
|
|
||||||
|
// For local mode with no search, fetch all local people
|
||||||
|
const { data: allLocalPeople = [], isLoading: allLocalLoading } = useSearchLocalPeople(
|
||||||
|
localOnly && !isSearching ? '*' : ''
|
||||||
|
);
|
||||||
|
|
||||||
|
// Determine displayed people
|
||||||
|
const displayPeople = useMemo(() => {
|
||||||
|
if (localOnly) {
|
||||||
|
const people = isSearching ? localSearchResults : allLocalPeople;
|
||||||
|
if (filter === 'favorite') {
|
||||||
|
return people.filter((p: any) => p.favorite);
|
||||||
|
}
|
||||||
|
return people;
|
||||||
|
}
|
||||||
|
// TMDB mode - filter not applicable for TMDB results
|
||||||
|
return tmdbPeople;
|
||||||
|
}, [localOnly, isSearching, localSearchResults, allLocalPeople, tmdbPeople, filter]);
|
||||||
|
|
||||||
const observerRef = useRef<IntersectionObserver | null>(null);
|
const observerRef = useRef<IntersectionObserver | null>(null);
|
||||||
const lastRef = useCallback(
|
const lastRef = useCallback(
|
||||||
(node: HTMLDivElement | null) => {
|
(node: HTMLDivElement | null) => {
|
||||||
if (activeQuery.isFetchingNextPage) return;
|
if (!activeQuery || activeQuery.isFetchingNextPage) return;
|
||||||
if (observerRef.current) observerRef.current.disconnect();
|
if (observerRef.current) observerRef.current.disconnect();
|
||||||
observerRef.current = new IntersectionObserver((entries) => {
|
observerRef.current = new IntersectionObserver((entries) => {
|
||||||
if (entries[0].isIntersecting && activeQuery.hasNextPage) {
|
if (entries[0].isIntersecting && activeQuery.hasNextPage) {
|
||||||
@@ -29,18 +67,24 @@ export function PeoplePage() {
|
|||||||
});
|
});
|
||||||
if (node) observerRef.current.observe(node);
|
if (node) observerRef.current.observe(node);
|
||||||
},
|
},
|
||||||
[activeQuery.isFetchingNextPage, activeQuery.hasNextPage, activeQuery.fetchNextPage]
|
[activeQuery?.isFetchingNextPage, activeQuery?.hasNextPage, activeQuery?.fetchNextPage]
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return () => observerRef.current?.disconnect();
|
return () => observerRef.current?.disconnect();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const isLoading = localOnly
|
||||||
|
? (isSearching ? localSearchLoading : allLocalLoading)
|
||||||
|
: activeQuery?.isLoading;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-6 animate-page-enter">
|
<div className="space-y-6 animate-page-enter">
|
||||||
<h1 className="text-2xl font-bold">People</h1>
|
<h1 className="text-2xl font-bold">People</h1>
|
||||||
|
|
||||||
<div className="relative max-w-xs">
|
{/* Controls row */}
|
||||||
|
<div className="flex flex-wrap items-center gap-3">
|
||||||
|
<div className="relative flex-1 max-w-xs">
|
||||||
<Search className="absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
|
<Search className="absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
|
||||||
<Input
|
<Input
|
||||||
placeholder="Search people..."
|
placeholder="Search people..."
|
||||||
@@ -50,7 +94,43 @@ export function PeoplePage() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{activeQuery.isLoading ? (
|
{/* Filter: All / Favorite (only in local mode) */}
|
||||||
|
{localOnly && (
|
||||||
|
<div className="flex items-center gap-1">
|
||||||
|
<Button
|
||||||
|
variant={filter === 'all' ? 'default' : 'outline'}
|
||||||
|
size="sm"
|
||||||
|
className="h-8 text-xs"
|
||||||
|
onClick={() => setFilter('all')}
|
||||||
|
>
|
||||||
|
All
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant={filter === 'favorite' ? 'default' : 'outline'}
|
||||||
|
size="sm"
|
||||||
|
className="h-8 text-xs gap-1"
|
||||||
|
onClick={() => setFilter('favorite')}
|
||||||
|
>
|
||||||
|
<Heart className="h-3 w-3" />
|
||||||
|
Favorite
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Local DB toggle */}
|
||||||
|
<div className="flex items-center gap-2 ml-auto">
|
||||||
|
<Switch
|
||||||
|
id="local-toggle"
|
||||||
|
checked={localOnly}
|
||||||
|
onCheckedChange={setLocalOnly}
|
||||||
|
/>
|
||||||
|
<Label htmlFor="local-toggle" className="text-sm cursor-pointer">
|
||||||
|
Local DB
|
||||||
|
</Label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{isLoading ? (
|
||||||
<div className="grid grid-cols-3 gap-4 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6 xl:grid-cols-8">
|
<div className="grid grid-cols-3 gap-4 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6 xl:grid-cols-8">
|
||||||
{Array.from({ length: 24 }).map((_, i) => (
|
{Array.from({ length: 24 }).map((_, i) => (
|
||||||
<div key={i} className="flex flex-col items-center gap-2">
|
<div key={i} className="flex flex-col items-center gap-2">
|
||||||
@@ -59,19 +139,24 @@ export function PeoplePage() {
|
|||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
) : displayPeople.length === 0 ? (
|
||||||
|
<div className="flex h-40 items-center justify-center text-muted-foreground">
|
||||||
|
No people found.
|
||||||
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="grid grid-cols-3 gap-4 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6 xl:grid-cols-8">
|
<div className="grid grid-cols-3 gap-4 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6 xl:grid-cols-8">
|
||||||
{people.map((person, index) => (
|
{displayPeople.map((person: any, index: number) => (
|
||||||
<div
|
<div
|
||||||
key={person.id}
|
key={person.id}
|
||||||
ref={index === people.length - 1 ? lastRef : undefined}
|
ref={!localOnly && index === displayPeople.length - 1 ? lastRef : undefined}
|
||||||
className="animate-card-enter"
|
className="animate-card-enter"
|
||||||
style={{ animationDelay: `${Math.min(index * 20, 300)}ms` }}
|
style={{ animationDelay: `${Math.min(index * 20, 300)}ms` }}
|
||||||
>
|
>
|
||||||
<Link
|
<Link
|
||||||
to={`/people/tmdb/${person.id}`}
|
to={localOnly ? `/people/${person.id}` : `/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"
|
||||||
>
|
>
|
||||||
|
<div className="relative">
|
||||||
<Avatar className="h-24 w-24 transition-transform group-hover:scale-105">
|
<Avatar className="h-24 w-24 transition-transform group-hover:scale-105">
|
||||||
<AvatarImage
|
<AvatarImage
|
||||||
src={getProfileUrl(person.profile_path)}
|
src={getProfileUrl(person.profile_path)}
|
||||||
@@ -80,10 +165,14 @@ export function PeoplePage() {
|
|||||||
<AvatarFallback>
|
<AvatarFallback>
|
||||||
{person.name
|
{person.name
|
||||||
.split(' ')
|
.split(' ')
|
||||||
.map((n) => n[0])
|
.map((n: string) => n[0])
|
||||||
.join('')}
|
.join('')}
|
||||||
</AvatarFallback>
|
</AvatarFallback>
|
||||||
</Avatar>
|
</Avatar>
|
||||||
|
{person.favorite && (
|
||||||
|
<Heart className="absolute -top-1 -right-1 h-4 w-4 fill-red-500 text-red-500" />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
<p className="text-sm font-medium line-clamp-2">
|
<p className="text-sm font-medium line-clamp-2">
|
||||||
{person.name}
|
{person.name}
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useParams } from 'react-router-dom';
|
import { useParams, useNavigate } from 'react-router-dom';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { usePerson, usePersonTmdbFilmography } from '@/hooks/usePeople';
|
import { usePerson, usePersonTmdbFilmography, useUpdatePerson } from '@/hooks/usePeople';
|
||||||
import { useLibrary } from '@/hooks/useEntries';
|
import { useLibrary } from '@/hooks/useEntries';
|
||||||
import { useLibraryStore } from '@/stores/useLibraryStore';
|
import { useLibraryStore } from '@/stores/useLibraryStore';
|
||||||
import { Skeleton } from '@/components/ui/skeleton';
|
import { Skeleton } from '@/components/ui/skeleton';
|
||||||
@@ -9,19 +9,35 @@ import { Separator } from '@/components/ui/separator';
|
|||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
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 { ChevronLeft, ChevronRight } from 'lucide-react';
|
import { ChevronLeft, ChevronRight, Heart } from 'lucide-react';
|
||||||
import type { TmdbEntry } from '@/types';
|
import type { TmdbEntry } from '@/types';
|
||||||
import type { TmdbFilmographyItem } from '@/api/people';
|
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 navigate = useNavigate();
|
||||||
|
const { data: person, isLoading, isError } = usePerson(personId);
|
||||||
const { data: tmdbFilmography, isLoading: tmdbLoading } = usePersonTmdbFilmography(personId);
|
const { data: tmdbFilmography, isLoading: tmdbLoading } = usePersonTmdbFilmography(personId);
|
||||||
|
const updatePerson = useUpdatePerson();
|
||||||
useLibrary();
|
useLibrary();
|
||||||
const libraryMap = useLibraryStore((s) => s.entries);
|
const libraryMap = useLibraryStore((s) => s.entries);
|
||||||
const libraryLoaded = useLibraryStore((s) => s.isLoaded);
|
const libraryLoaded = useLibraryStore((s) => s.isLoaded);
|
||||||
|
|
||||||
|
if (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">
|
||||||
|
This person could not be loaded. They may not exist in the database.
|
||||||
|
</p>
|
||||||
|
<Button variant="outline" onClick={() => navigate('/people')}>
|
||||||
|
Back to People
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (isLoading || !person) {
|
if (isLoading || !person) {
|
||||||
return (
|
return (
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
@@ -47,7 +63,18 @@ export function PersonDetailsPage() {
|
|||||||
</AvatarFallback>
|
</AvatarFallback>
|
||||||
</Avatar>
|
</Avatar>
|
||||||
<div className="space-y-2 text-center sm:text-left sm:space-y-3">
|
<div className="space-y-2 text-center sm:text-left sm:space-y-3">
|
||||||
|
<div className="flex items-center gap-2 justify-center sm:justify-start">
|
||||||
<h1 className="text-2xl font-bold sm:text-3xl">{person.name}</h1>
|
<h1 className="text-2xl font-bold sm:text-3xl">{person.name}</h1>
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
className="h-8 w-8 shrink-0"
|
||||||
|
onClick={() => updatePerson.mutate({ id: person.id, data: { favorite: !person.favorite } })}
|
||||||
|
disabled={updatePerson.isPending}
|
||||||
|
>
|
||||||
|
<Heart className={`h-5 w-5 ${person.favorite ? 'fill-red-500 text-red-500' : 'text-muted-foreground'}`} />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
<div className="flex flex-wrap items-center justify-center gap-2 text-sm text-muted-foreground sm:justify-start sm:gap-3">
|
<div className="flex flex-wrap items-center justify-center gap-2 text-sm text-muted-foreground sm:justify-start sm:gap-3">
|
||||||
{person.known_for_department && <span>{person.known_for_department}</span>}
|
{person.known_for_department && <span>{person.known_for_department}</span>}
|
||||||
{person.birthday && (<><span>•</span><span>Born: {formatDate(person.birthday)}</span></>)}
|
{person.birthday && (<><span>•</span><span>Born: {formatDate(person.birthday)}</span></>)}
|
||||||
|
|||||||
@@ -9,8 +9,9 @@ import { Skeleton } from '@/components/ui/skeleton';
|
|||||||
import { Progress } from '@/components/ui/progress';
|
import { Progress } from '@/components/ui/progress';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Eye, CheckCircle2, ListChecks } from 'lucide-react';
|
import { Eye, CheckCircle2, ListChecks } from 'lucide-react';
|
||||||
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
|
||||||
import { getTmdbPosterUrl, getYear, formatDate } from '@/lib/media-utils';
|
import { getTmdbPosterUrl, getYear, formatDate } from '@/lib/media-utils';
|
||||||
import type { Episode } from '@/types';
|
import type { Episode, EpisodeSeen } from '@/types';
|
||||||
|
|
||||||
export function SeasonPage() {
|
export function SeasonPage() {
|
||||||
const { entryId, seasonId } = useParams<{
|
const { entryId, seasonId } = useParams<{
|
||||||
@@ -39,7 +40,7 @@ export function SeasonPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const watchedCount = episodes.filter(
|
const watchedCount = episodes.filter(
|
||||||
(ep) =>
|
(ep: Episode) =>
|
||||||
ep.date_first_seen ||
|
ep.date_first_seen ||
|
||||||
(ep.episodeSeens && ep.episodeSeens.length > 0)
|
(ep.episodeSeens && ep.episodeSeens.length > 0)
|
||||||
).length;
|
).length;
|
||||||
@@ -61,20 +62,20 @@ export function SeasonPage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
<div className="flex gap-6">
|
<div className="flex flex-col gap-4 sm:flex-row sm:gap-6">
|
||||||
<img
|
<img
|
||||||
src={getTmdbPosterUrl(season.poster_path, 'w185')}
|
src={getTmdbPosterUrl(season.poster_path, 'w185')}
|
||||||
alt={season.name}
|
alt={season.name}
|
||||||
className="h-56 w-36 shrink-0 rounded-lg object-cover shadow-lg"
|
className="h-40 w-28 shrink-0 rounded-lg object-cover shadow-lg self-center sm:self-start sm:h-56 sm:w-36"
|
||||||
/>
|
/>
|
||||||
<div className="flex-1 flex flex-col justify-center space-y-3">
|
<div className="flex-1 flex flex-col justify-center space-y-3">
|
||||||
<div className="flex items-start justify-between gap-4">
|
<div className="flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between sm:gap-4">
|
||||||
<h1 className="text-2xl font-bold">{season.name}</h1>
|
<h1 className="text-xl font-bold sm:text-2xl">{season.name}</h1>
|
||||||
{/* Mark Season as Watched — top right */}
|
{/* Mark Season as Watched — top right */}
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
className="shrink-0"
|
className="shrink-0 w-full sm:w-auto"
|
||||||
onClick={() => setShowMarkAllDialog(true)}
|
onClick={() => setShowMarkAllDialog(true)}
|
||||||
>
|
>
|
||||||
<ListChecks className="mr-1.5 h-4 w-4" />
|
<ListChecks className="mr-1.5 h-4 w-4" />
|
||||||
@@ -113,19 +114,20 @@ export function SeasonPage() {
|
|||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
<h3 className="text-lg font-semibold">Episodes</h3>
|
<h3 className="text-lg font-semibold">Episodes</h3>
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
{episodes.map((episode) => {
|
{episodes.map((episode: Episode) => {
|
||||||
const isWatched =
|
const isWatched =
|
||||||
!!episode.date_first_seen ||
|
!!episode.date_first_seen ||
|
||||||
(episode.episodeSeens && episode.episodeSeens.length > 0);
|
(episode.episodeSeens && episode.episodeSeens.length > 0);
|
||||||
|
const seenDates = (episode.episodeSeens ?? []).map((s: EpisodeSeen) => s.date_seen);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Link
|
<Link
|
||||||
key={episode.id}
|
key={episode.id}
|
||||||
to={`/entry/${entryId}/season/${seasonId}/episode/${episode.id}`}
|
to={`/entry/${entryId}/season/${seasonId}/episode/${episode.id}`}
|
||||||
className="flex gap-4 rounded-lg border border-border p-3 transition-colors hover:bg-accent/50"
|
className="flex gap-3 rounded-lg border border-border p-2 transition-colors hover:bg-accent/50 sm:gap-4 sm:p-3"
|
||||||
>
|
>
|
||||||
{/* Thumbnail */}
|
{/* Thumbnail */}
|
||||||
<div className="h-16 w-28 shrink-0 overflow-hidden rounded bg-muted">
|
<div className="h-14 w-24 shrink-0 overflow-hidden rounded bg-muted sm:h-16 sm:w-28">
|
||||||
{episode.still_path ? (
|
{episode.still_path ? (
|
||||||
<img
|
<img
|
||||||
src={getTmdbPosterUrl(episode.still_path, 'w300')}
|
src={getTmdbPosterUrl(episode.still_path, 'w300')}
|
||||||
@@ -153,11 +155,40 @@ export function SeasonPage() {
|
|||||||
<CheckCircle2 className="h-4 w-4 shrink-0 text-green-500" />
|
<CheckCircle2 className="h-4 w-4 shrink-0 text-green-500" />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex items-center gap-2 flex-wrap">
|
||||||
{episode.air_date && (
|
{episode.air_date && (
|
||||||
<p className="text-xs text-muted-foreground">
|
<p className="text-xs text-muted-foreground">
|
||||||
{formatDate(episode.air_date)}
|
{formatDate(episode.air_date)}
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
|
{seenDates.length > 0 && (
|
||||||
|
<>
|
||||||
|
<span className="text-xs text-muted-foreground">•</span>
|
||||||
|
{seenDates.length === 1 ? (
|
||||||
|
<span className="text-xs text-green-600 dark:text-green-400">
|
||||||
|
Seen {formatDate(seenDates[0])}
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
<TooltipProvider>
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger>
|
||||||
|
<span className="text-xs text-green-600 dark:text-green-400 cursor-default underline decoration-dotted">
|
||||||
|
Seen {seenDates.length} times
|
||||||
|
</span>
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent>
|
||||||
|
<div className="space-y-0.5 text-xs">
|
||||||
|
{seenDates.map((d: string, i: number) => (
|
||||||
|
<p key={i}>{formatDate(d)}</p>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
</TooltipProvider>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
{episode.overview && (
|
{episode.overview && (
|
||||||
<p className="mt-1 text-xs text-muted-foreground line-clamp-2">
|
<p className="mt-1 text-xs text-muted-foreground line-clamp-2">
|
||||||
{episode.overview}
|
{episode.overview}
|
||||||
@@ -165,7 +196,7 @@ export function SeasonPage() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Watch button */}
|
{/* Watch button — always clickable to add another seen record */}
|
||||||
<Button
|
<Button
|
||||||
size="icon"
|
size="icon"
|
||||||
variant={isWatched ? 'secondary' : 'outline'}
|
variant={isWatched ? 'secondary' : 'outline'}
|
||||||
@@ -173,11 +204,8 @@ export function SeasonPage() {
|
|||||||
onClick={(ev) => {
|
onClick={(ev) => {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
if (!isWatched) {
|
|
||||||
setDialogEpisode(episode);
|
setDialogEpisode(episode);
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
disabled={isWatched}
|
|
||||||
>
|
>
|
||||||
<Eye className="h-4 w-4" />
|
<Eye className="h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -0,0 +1,213 @@
|
|||||||
|
import { useParams, useNavigate } from 'react-router-dom';
|
||||||
|
import { useTmdbPreview, useCreateEntry } from '@/hooks/useEntries';
|
||||||
|
import { useLibraryStore } from '@/stores/useLibraryStore';
|
||||||
|
import { Badge } from '@/components/ui/badge';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { Separator } from '@/components/ui/separator';
|
||||||
|
import { Star, Plus, Loader2, ExternalLink, Tv, Film } from 'lucide-react';
|
||||||
|
import { EntryDetailsSkeleton } from '@/components/skeletons/PageSkeletons';
|
||||||
|
import { getYear, formatRuntime } from '@/lib/media-utils';
|
||||||
|
|
||||||
|
const TMDB_IMG = 'https://image.tmdb.org/t/p';
|
||||||
|
|
||||||
|
export function TmdbPreviewPage() {
|
||||||
|
const { type, tmdbId } = useParams<{ type: string; tmdbId: string }>();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const tmdbIdNum = parseInt(tmdbId!, 10);
|
||||||
|
const mediaType = type as 'movie' | 'tv';
|
||||||
|
|
||||||
|
const { data: preview, isLoading, isError } = useTmdbPreview(tmdbIdNum, mediaType);
|
||||||
|
const createEntry = useCreateEntry();
|
||||||
|
|
||||||
|
// Check if already in library
|
||||||
|
const libraryEntry = useLibraryStore((s) => {
|
||||||
|
for (const e of s.entries.values()) {
|
||||||
|
if (e.entryIds?.tmdb_id === tmdbIdNum) return e;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (isLoading || !preview) {
|
||||||
|
return <EntryDetailsSkeleton />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isError) {
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col items-center justify-center gap-4 py-20">
|
||||||
|
<p className="text-muted-foreground">Could not load entry from TMDB.</p>
|
||||||
|
<Button variant="outline" onClick={() => navigate(-1)}>Go back</Button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const backdrop = preview.backdrop_path ? `${TMDB_IMG}/w1280${preview.backdrop_path}` : null;
|
||||||
|
const poster = preview.poster_path
|
||||||
|
? `${TMDB_IMG}/w500${preview.poster_path}`
|
||||||
|
: '/images/default-poster.png';
|
||||||
|
|
||||||
|
const handleAddToLibrary = () => {
|
||||||
|
createEntry.mutate(
|
||||||
|
{ tmdb_id: preview.tmdb_id, is_tvserie: preview.is_tvseries },
|
||||||
|
{ onSuccess: (newEntry) => navigate(`/entry/${newEntry.id}`, { replace: true }) }
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
{/* Backdrop banner */}
|
||||||
|
<div className="relative -mx-6 -mt-6 h-52 overflow-hidden">
|
||||||
|
{backdrop ? (
|
||||||
|
<img
|
||||||
|
src={backdrop}
|
||||||
|
alt=""
|
||||||
|
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-linear-to-t from-background via-background/60 to-transparent" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Main content */}
|
||||||
|
<div className="mx-auto max-w-4xl">
|
||||||
|
{/* Add to Library button — top right */}
|
||||||
|
<div className="flex justify-end gap-2 -mt-10 relative z-10 mb-2">
|
||||||
|
{libraryEntry ? (
|
||||||
|
<Button variant="outline" onClick={() => navigate(`/entry/${libraryEntry.id}`)}>
|
||||||
|
Already in Library — View
|
||||||
|
</Button>
|
||||||
|
) : (
|
||||||
|
<Button onClick={handleAddToLibrary} disabled={createEntry.isPending}>
|
||||||
|
{createEntry.isPending ? (
|
||||||
|
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
||||||
|
) : (
|
||||||
|
<Plus className="mr-2 h-4 w-4" />
|
||||||
|
)}
|
||||||
|
{createEntry.isPending ? 'Adding...' : 'Add to Library'}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Two-column header: poster | info */}
|
||||||
|
<div className="flex flex-col gap-6 relative items-start sm:flex-row sm:gap-8 sm:-mt-8">
|
||||||
|
{/* LEFT: Poster */}
|
||||||
|
<div className="w-32 sm:w-44 shrink-0 self-start mx-auto sm:mx-0">
|
||||||
|
<img
|
||||||
|
src={poster}
|
||||||
|
alt={preview.title}
|
||||||
|
className="w-full aspect-2/3 rounded-xl object-cover shadow-2xl ring-1 ring-border/50"
|
||||||
|
/>
|
||||||
|
{/* External links */}
|
||||||
|
<div className="flex items-center justify-center gap-3 mt-3">
|
||||||
|
{preview.tmdb_id && (
|
||||||
|
<a
|
||||||
|
href={`https://www.themoviedb.org/${preview.is_tvseries ? 'tv' : 'movie'}/${preview.tmdb_id}`}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
className="inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors"
|
||||||
|
>
|
||||||
|
<ExternalLink className="h-3 w-3" />
|
||||||
|
TMDB
|
||||||
|
</a>
|
||||||
|
)}
|
||||||
|
{preview.imdb_id && (
|
||||||
|
<a
|
||||||
|
href={`https://www.imdb.com/title/${preview.imdb_id}`}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
className="inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors"
|
||||||
|
>
|
||||||
|
<ExternalLink className="h-3 w-3" />
|
||||||
|
IMDb
|
||||||
|
</a>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* RIGHT: Info */}
|
||||||
|
<div className="flex-1 min-w-0 space-y-4">
|
||||||
|
{/* Title */}
|
||||||
|
<div className="space-y-1">
|
||||||
|
<h1 className="text-3xl font-bold leading-tight">{preview.title}</h1>
|
||||||
|
{preview.tagline && (
|
||||||
|
<p className="text-sm text-muted-foreground italic">{preview.tagline}</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Meta */}
|
||||||
|
<div className="flex flex-wrap items-center gap-2 text-sm text-muted-foreground">
|
||||||
|
<span className="inline-flex items-center gap-1">
|
||||||
|
{preview.is_tvseries ? <Tv className="h-3.5 w-3.5" /> : <Film className="h-3.5 w-3.5" />}
|
||||||
|
{preview.is_tvseries ? 'TV Series' : 'Movie'}
|
||||||
|
</span>
|
||||||
|
{preview.release_date && (
|
||||||
|
<>
|
||||||
|
<span>•</span>
|
||||||
|
<span>{getYear(preview.release_date)}</span>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{preview.is_tvseries && preview.status && (
|
||||||
|
<>
|
||||||
|
<span>•</span>
|
||||||
|
<span>{preview.status}</span>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{preview.runtime && !preview.is_tvseries && (
|
||||||
|
<>
|
||||||
|
<span>•</span>
|
||||||
|
<span>{formatRuntime(preview.runtime)}</span>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* TV series season count */}
|
||||||
|
{preview.is_tvseries && preview.number_of_seasons != null && (
|
||||||
|
<div className="flex items-center gap-2 text-sm">
|
||||||
|
<Badge variant="secondary">
|
||||||
|
{preview.number_of_seasons} {preview.number_of_seasons === 1 ? 'Season' : 'Seasons'}
|
||||||
|
</Badge>
|
||||||
|
{preview.number_of_episodes != null && (
|
||||||
|
<span className="text-muted-foreground">
|
||||||
|
({preview.number_of_episodes} episodes)
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Genres */}
|
||||||
|
{preview.genres.length > 0 && (
|
||||||
|
<div className="flex flex-wrap gap-1.5">
|
||||||
|
{preview.genres.map((g) => (
|
||||||
|
<Badge key={g.id} variant="outline" className="text-xs">
|
||||||
|
{g.name}
|
||||||
|
</Badge>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Rating */}
|
||||||
|
{preview.vote_average != null && preview.vote_average > 0 && (
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<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">
|
||||||
|
<Star className="h-3.5 w-3.5 fill-current" />
|
||||||
|
<span className="font-bold">TMDB:</span>
|
||||||
|
{preview.vote_average.toFixed(1)}/10
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Storyline */}
|
||||||
|
{preview.storyline && (
|
||||||
|
<>
|
||||||
|
<Separator />
|
||||||
|
<p className="text-sm text-muted-foreground leading-relaxed max-w-prose">
|
||||||
|
{preview.storyline}
|
||||||
|
</p>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -52,6 +52,11 @@ const EntryDetailsPage = lazy(() =>
|
|||||||
default: m.EntryDetailsPage,
|
default: m.EntryDetailsPage,
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
|
const TmdbPreviewPage = lazy(() =>
|
||||||
|
import('@/pages/TmdbPreviewPage').then((m) => ({
|
||||||
|
default: m.TmdbPreviewPage,
|
||||||
|
}))
|
||||||
|
);
|
||||||
const SeasonPage = lazy(() =>
|
const SeasonPage = lazy(() =>
|
||||||
import('@/pages/SeasonPage').then((m) => ({ default: m.SeasonPage }))
|
import('@/pages/SeasonPage').then((m) => ({ default: m.SeasonPage }))
|
||||||
);
|
);
|
||||||
@@ -169,6 +174,14 @@ export const router = createBrowserRouter([
|
|||||||
</SuspensePage>
|
</SuspensePage>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/entry/tmdb/:type/:tmdbId',
|
||||||
|
element: (
|
||||||
|
<SuspensePage fallback={<EntryDetailsSkeleton />}>
|
||||||
|
<TmdbPreviewPage />
|
||||||
|
</SuspensePage>
|
||||||
|
),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/entry/:id',
|
path: '/entry/:id',
|
||||||
element: (
|
element: (
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
import { create } from 'zustand';
|
||||||
|
|
||||||
|
type FilterTab = 'all' | 'movies' | 'tv' | 'favorites' | 'hidden';
|
||||||
|
type SortField = 'date_last_seen' | 'createdAt' | 'title' | 'release_date' | 'rating';
|
||||||
|
type SortDir = 'asc' | 'desc';
|
||||||
|
|
||||||
|
interface Filters {
|
||||||
|
genre: string;
|
||||||
|
tmdbRatingMin: string;
|
||||||
|
tmdbRatingMax: string;
|
||||||
|
userRatingMin: string;
|
||||||
|
userRatingMax: string;
|
||||||
|
yearMin: string;
|
||||||
|
yearMax: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface LibraryFiltersState {
|
||||||
|
activeTab: FilterTab;
|
||||||
|
search: string;
|
||||||
|
sortField: SortField;
|
||||||
|
sortDir: SortDir;
|
||||||
|
filters: Filters;
|
||||||
|
|
||||||
|
setActiveTab: (tab: FilterTab) => void;
|
||||||
|
setSearch: (search: string) => void;
|
||||||
|
setSortField: (field: SortField) => void;
|
||||||
|
setSortDir: (dir: SortDir) => void;
|
||||||
|
setFilters: (updater: Filters | ((prev: Filters) => Filters)) => void;
|
||||||
|
clearFilters: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultFilters: Filters = {
|
||||||
|
genre: '',
|
||||||
|
tmdbRatingMin: '',
|
||||||
|
tmdbRatingMax: '',
|
||||||
|
userRatingMin: '',
|
||||||
|
userRatingMax: '',
|
||||||
|
yearMin: '',
|
||||||
|
yearMax: '',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useLibraryFiltersStore = create<LibraryFiltersState>((set) => ({
|
||||||
|
activeTab: 'all',
|
||||||
|
search: '',
|
||||||
|
sortField: 'date_last_seen',
|
||||||
|
sortDir: 'desc',
|
||||||
|
filters: defaultFilters,
|
||||||
|
|
||||||
|
setActiveTab: (tab) => set({ activeTab: tab }),
|
||||||
|
setSearch: (search) => set({ search }),
|
||||||
|
setSortField: (field) => set({ sortField: field }),
|
||||||
|
setSortDir: (dir) => set({ sortDir: dir }),
|
||||||
|
setFilters: (updater) =>
|
||||||
|
set((state) => ({
|
||||||
|
filters: typeof updater === 'function' ? updater(state.filters) : updater,
|
||||||
|
})),
|
||||||
|
clearFilters: () => set({ filters: defaultFilters }),
|
||||||
|
}));
|
||||||
|
|
||||||
|
export { defaultFilters };
|
||||||
|
export type { FilterTab, SortField, SortDir, Filters };
|
||||||
@@ -152,6 +152,8 @@ export interface People {
|
|||||||
place_of_birth: string | null;
|
place_of_birth: string | null;
|
||||||
known_for_department: string | null;
|
known_for_department: string | null;
|
||||||
fully_fetched: boolean;
|
fully_fetched: boolean;
|
||||||
|
favorite: boolean;
|
||||||
|
pinned: boolean;
|
||||||
profile_path: string | null;
|
profile_path: string | null;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
@@ -241,3 +243,25 @@ export interface TmdbPaginatedResponse<T> {
|
|||||||
total_pages: number;
|
total_pages: number;
|
||||||
total_results: number;
|
total_results: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface TmdbPreview {
|
||||||
|
tmdb_id: number;
|
||||||
|
title: string;
|
||||||
|
original_title: string | null;
|
||||||
|
release_date: string | null;
|
||||||
|
runtime: number | null;
|
||||||
|
storyline: string | null;
|
||||||
|
country: string | null;
|
||||||
|
is_tvseries: boolean;
|
||||||
|
status: string | null;
|
||||||
|
poster_path: string | null;
|
||||||
|
backdrop_path: string | null;
|
||||||
|
vote_average: number | null;
|
||||||
|
genres: { id: number; name: string }[];
|
||||||
|
tagline: string | null;
|
||||||
|
number_of_seasons: number | null;
|
||||||
|
number_of_episodes: number | null;
|
||||||
|
networks: { id: number; name: string; logo_path: string | null }[];
|
||||||
|
homepage: string | null;
|
||||||
|
imdb_id: string | null;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user