Complete frontend refactoring: UI enhancements, pagination, filtering, search architecture, and data management improvements
# Phase 1: Feature Implementation
- Add "Create new..." option in `AddEntryToCollectionDialog` for inline collection creation with auto-select
- Implement lazy loading pagination with IntersectionObserver for Watchlist, Collections, and Media pages
- Add reusable useDebounce hook (300-400ms) and apply to all search inputs across pages
- Reset scroll position to top when switching between sidebar navigation pages via useLocation()
- Reorganize MediaPage with horizontal control layout, add Media Type filter (All/Audio/Video), and Custom Media filter (Show All/Official Only/Custom Only)
- Add three-dot menu (MoreHorizontal icon) to collection cards with Edit/Delete options and "Get all parts" feature
- Replace numeric rating input with interactive star rating component in EditCollectionDialog (0-10 stars with half-star support)
- Display entry type badges ("Movie" / "TV Series") on home page trending/popular sections and search results
- Create PeopleSearchResult component with profile images; integrate useTmdbSearchPeople hook linking to `/people/tmdb/:tmdbId`
- Add TMDB Rating and User Rating filters to Library page with range sliders (0-10, step 1) and state persistence in useLibraryStore
- Add All/Movies/TV Series type filter to Watchlist page with filtered count display
- Improve People Details page mobile UI: optimize header, info section sizing, and filmography card layouts for touch
# Phase 2: Architecture Refactoring & Bug Fixes
- Fix scroll-to-top on sidebar navigation by constraining AppLayout root to `h-screen overflow-hidden` so `<main>` becomes proper scroll container
- Extract search from HomePage into dedicated SearchPage component with `/search` route, debounced input, and URL query sync via SearchParams
- Add Search nav item with icon to sidebar for easy search access
- HomePage search input now navigates to `/search?q=...` instead of handling inline, separating concerns and enabling search bookmarking
- Entry type pill badges now conditionally render via `showTypeBadge` prop on EntryCard—only SearchPage passes this to prevent display on home/discover pages
- Fix people ID bug: people search results now link to `/people/tmdb/:tmdbId` (TMDB redirect route) instead of `/people/:id`, correctly mapping TMDB IDs to local database IDs through PersonTmdbRedirectPage
- Enhance People Details filmography sorting: "Not in Library" section now detects self roles (self/themselves/himself/herself) and sorts non-self by release date (new→old) with all self roles pushed to end of list
# Summary
- Created new files: SearchPage.tsx, useDebounce.ts
This commit is contained in:
1 parent
d28b4caa7e
commit
9a8ee181e5
23 files changed
+680
-188
No files matched your search
@@ -1,18 +1,30 @@
|
||||
import { useState } from 'react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { useCollection } from '@/hooks/useCollections';
|
||||
import { useParams, useNavigate } from 'react-router-dom';
|
||||
import { useCollection, useDeleteCollection, useGetCollectionParts } from '@/hooks/useCollections';
|
||||
import { EntryLibraryGrid } from '@/components/entries/EntryLibraryGrid';
|
||||
import { getCollectionPosterUrl } from '@/lib/media-utils';
|
||||
import { getTmdbImageUrl } from '@/lib/api';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Star, Pencil } from 'lucide-react';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import { Star, MoreVertical, Pencil, Download, Trash2 } from 'lucide-react';
|
||||
import { CollectionEditDialog } from '@/components/dialogs/CollectionEditDialog';
|
||||
import { ConfirmDialog } from '@/components/dialogs/ConfirmDialog';
|
||||
import { toast } from 'sonner';
|
||||
|
||||
export function CollectionDetailsPage() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const { data: collection, isLoading } = useCollection(Number(id));
|
||||
const navigate = useNavigate();
|
||||
const { data: collection, isLoading, isError } = useCollection(Number(id));
|
||||
const [showEditDialog, setShowEditDialog] = useState(false);
|
||||
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
|
||||
const deleteCollection = useDeleteCollection();
|
||||
const getCollectionParts = useGetCollectionParts();
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
@@ -28,12 +40,10 @@ export function CollectionDetailsPage() {
|
||||
);
|
||||
}
|
||||
|
||||
if (!collection) {
|
||||
return (
|
||||
<div className="flex h-40 items-center justify-center text-muted-foreground">
|
||||
Collection not found.
|
||||
</div>
|
||||
);
|
||||
if (!collection || isError) {
|
||||
toast.error('Collection not found');
|
||||
navigate('/collections', { replace: true });
|
||||
return null;
|
||||
}
|
||||
|
||||
const backdropUrl = collection.backdrop_path
|
||||
@@ -45,6 +55,16 @@ export function CollectionDetailsPage() {
|
||||
isInLibrary: true,
|
||||
}));
|
||||
|
||||
const handleDelete = () => {
|
||||
deleteCollection.mutate(collection.id, {
|
||||
onSuccess: () => navigate('/collections', { replace: true }),
|
||||
});
|
||||
};
|
||||
|
||||
const handleGetParts = () => {
|
||||
getCollectionParts.mutate(collection.id);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-6 animate-page-enter">
|
||||
{/* Hero banner */}
|
||||
@@ -59,7 +79,36 @@ export function CollectionDetailsPage() {
|
||||
<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 bottom-0 left-0 right-0 flex items-end justify-between p-6">
|
||||
|
||||
{/* Quick action menu - top right */}
|
||||
<div className="absolute top-3 right-3">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="secondary" size="icon" className="h-8 w-8">
|
||||
<MoreVertical className="h-4 w-4" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem onClick={() => setShowEditDialog(true)}>
|
||||
<Pencil className="mr-2 h-4 w-4" />
|
||||
Edit
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={handleGetParts} disabled={getCollectionParts.isPending}>
|
||||
<Download className="mr-2 h-4 w-4" />
|
||||
{getCollectionParts.isPending ? 'Fetching...' : 'Get All Parts'}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
className="text-destructive focus:text-destructive"
|
||||
onClick={() => setShowDeleteConfirm(true)}
|
||||
>
|
||||
<Trash2 className="mr-2 h-4 w-4" />
|
||||
Delete
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
|
||||
<div className="absolute bottom-0 left-0 right-0 flex items-end p-6">
|
||||
<div className="flex items-end gap-4">
|
||||
<img
|
||||
src={getCollectionPosterUrl(collection)}
|
||||
@@ -90,15 +139,6 @@ export function CollectionDetailsPage() {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
className="shrink-0"
|
||||
onClick={() => setShowEditDialog(true)}
|
||||
>
|
||||
<Pencil className="mr-1 h-4 w-4" />
|
||||
Edit
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -113,6 +153,17 @@ export function CollectionDetailsPage() {
|
||||
collection={collection}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Delete confirmation */}
|
||||
<ConfirmDialog
|
||||
open={showDeleteConfirm}
|
||||
onOpenChange={setShowDeleteConfirm}
|
||||
title="Delete Collection"
|
||||
description={`Are you sure you want to delete "${collection.name}"? This action cannot be undone.`}
|
||||
confirmLabel="Delete"
|
||||
onConfirm={handleDelete}
|
||||
variant="destructive"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user