Implemented the new react version of the frontend

This commit is contained in:
Mohammed Abad committed 2026-03-31 01:56:38 +01:00
1 parent 236e6e06fb
commit ffe7e52527
65 files changed
+5228 -177

No files matched your search

@@ -0,0 +1,118 @@
import { useState } from 'react';
import { useParams } from 'react-router-dom';
import { useCollection } 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 { CollectionEditDialog } from '@/components/dialogs/CollectionEditDialog';
export function CollectionDetailsPage() {
const { id } = useParams<{ id: string }>();
const { data: collection, isLoading } = useCollection(Number(id));
const [showEditDialog, setShowEditDialog] = useState(false);
if (isLoading) {
return (
<div className="space-y-6">
<Skeleton className="h-48 w-full rounded-xl" />
<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">
{Array.from({ length: 6 }).map((_, i) => (
<Skeleton key={i} className="aspect-[2/3] w-full rounded-lg" />
))}
</div>
</div>
);
}
if (!collection) {
return (
<div className="flex h-40 items-center justify-center text-muted-foreground">
Collection not found.
</div>
);
}
const backdropUrl = collection.backdrop_path
? getTmdbImageUrl(collection.backdrop_path, 'w1280')
: null;
const entries = (collection.entries || []).map((e) => ({
...e,
isInLibrary: true,
}));
return (
<div className="space-y-6">
{/* Hero banner */}
<div className="relative overflow-hidden rounded-xl">
{backdropUrl ? (
<img
src={backdropUrl}
alt={collection.name}
className="h-48 w-full object-cover 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 bottom-0 left-0 right-0 flex items-end justify-between p-6">
<div className="flex items-end gap-4">
<img
src={getCollectionPosterUrl(collection)}
alt={collection.name}
className="h-32 w-auto rounded-lg shadow-lg sm:h-40"
/>
<div className="space-y-1">
<h1 className="text-2xl font-bold text-white sm:text-3xl">
{collection.name}
</h1>
{collection.description && (
<p className="max-w-xl text-sm text-white/80 line-clamp-3">
{collection.description}
</p>
)}
<div className="flex items-center gap-3">
<p className="text-sm text-white/60">
{entries.length} {entries.length === 1 ? 'entry' : 'entries'}
</p>
{collection.user_rating != null && collection.user_rating > 0 && (
<div className="flex items-center gap-1">
<Star className="h-4 w-4 fill-yellow-400 text-yellow-400" />
<span className="text-sm font-medium text-white">
{collection.user_rating}/10
</span>
</div>
)}
</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>
{/* Entries grid */}
<EntryLibraryGrid entries={entries} isLoading={false} />
{/* Edit dialog */}
{showEditDialog && (
<CollectionEditDialog
open={showEditDialog}
onOpenChange={setShowEditDialog}
collection={collection}
/>
)}
</div>
);
}