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,354 @@
import { useState } from 'react';
import { useParams } from 'react-router-dom';
import { useEntry, useEntrySeasons, useRefreshEntry } from '@/hooks/useEntries';
import { useEntrySeenByEntry, useDeleteEntrySeen } from '@/hooks/useEntrySeen';
import { useLibraryStore } from '@/stores/useLibraryStore';
import { Skeleton } from '@/components/ui/skeleton';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { Separator } from '@/components/ui/separator';
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu';
import {
Heart,
MoreHorizontal,
Eye,
EyeOff,
RefreshCw,
FolderPlus,
ImageIcon,
Settings,
Star,
} from 'lucide-react';
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from '@/components/ui/tooltip';
import { CastList } from '@/components/entries/CastList';
import { SeasonsContainer } from '@/components/entries/SeasonsContainer';
import { EpisodeWatchHistory } from '@/components/entries/EpisodeWatchHistory';
import { CollectionsGrid } from '@/components/collections/CollectionsGrid';
import { EntrySettingsDialog } from '@/components/dialogs/EntrySettingsDialog';
import { EntrySeenDialog } from '@/components/dialogs/EntrySeenDialog';
import { EntryMediaDialog } from '@/components/dialogs/EntryMediaDialog';
import { AddEntryToCollectionDialog } from '@/components/dialogs/AddEntryToCollectionDialog';
import {
getPosterUrl,
getBackdropUrl,
getYear,
formatRuntime,
formatDate,
} from '@/lib/media-utils';
import { useUpdateEntry } from '@/hooks/useEntries';
import type { Entry } from '@/types';
export function EntryDetailsPage() {
const { id } = useParams<{ id: string }>();
const entryId = parseInt(id!, 10);
const { data: entry, isLoading } = useEntry(entryId);
const { data: seasons } = useEntrySeasons(entryId);
const { data: watchHistory = [] } = useEntrySeenByEntry(entryId);
const updateEntry = useUpdateEntry();
const refreshEntry = useRefreshEntry();
const deleteEntrySeen = useDeleteEntrySeen();
// Merge library entry with detail entry so we get both library flags AND full details (credits, etc.)
const libraryEntry = useLibraryStore((s) => s.entries.get(entryId));
const displayEntry = libraryEntry && entry
? { ...libraryEntry, ...entry, isInLibrary: true }
: entry || libraryEntry;
// Dialog states
const [showSettings, setShowSettings] = useState(false);
const [showSeenDialog, setShowSeenDialog] = useState(false);
const [showMediaDialog, setShowMediaDialog] = useState(false);
const [showCollectionDialog, setShowCollectionDialog] = useState(false);
if (isLoading || !displayEntry) {
return <EntryDetailsSkeleton />;
}
const e = displayEntry;
const backdrop = getBackdropUrl(e);
const poster = getPosterUrl(e);
const director = e.credits?.find(
(c) => c.cast_type === 'crew' && c.job === 'Director'
);
const toggleFavorite = () => {
updateEntry.mutate({ id: e.id, data: { favorit: !e.favorit } });
};
return (
<div className="space-y-8">
{/* Hero Section */}
<div className="relative -mx-6 -mt-6 overflow-hidden">
{backdrop && (
<img
src={backdrop}
alt=""
className="h-72 w-full object-cover opacity-30 blur-sm"
/>
)}
<div className="absolute inset-0 bg-gradient-to-t from-background to-transparent" />
<div className="relative mx-auto flex max-w-5xl gap-6 px-6 pb-6 pt-4">
{/* Poster */}
<div className="shrink-0">
<img
src={poster}
alt={e.title}
className="h-72 w-48 rounded-lg object-cover shadow-lg"
/>
</div>
{/* Info */}
<div className="flex flex-1 flex-col justify-end space-y-3">
<div className="flex items-center gap-3">
<h1 className="text-3xl font-bold">{e.title}</h1>
{e.status && (
<Badge variant="secondary">{e.status}</Badge>
)}
</div>
<div className="flex flex-wrap items-center gap-2 text-sm text-muted-foreground">
{e.release_date && (
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
<span className="cursor-default underline decoration-dotted">
{getYear(e.release_date)}
</span>
</TooltipTrigger>
<TooltipContent>
<p>{formatDate(e.release_date)}</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
)}
{e.runtime && !e.is_tvseries && (
<>
<span>•</span>
<span>{formatRuntime(e.runtime)}</span>
</>
)}
{director && (
<>
<span>•</span>
<span>Dir. {director.people?.name}</span>
</>
)}
</div>
{/* Genres */}
{e.genres && e.genres.length > 0 && (
<div className="flex flex-wrap gap-1.5">
{e.genres.map((g) => (
<Badge key={g.id} variant="outline" className="text-xs">
{g.name}
</Badge>
))}
</div>
)}
{/* Ratings */}
<div className="flex items-center gap-4">
{e.entryRatings?.user_rating != null &&
e.entryRatings.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">
{e.entryRatings.user_rating}/10
</span>
<span className="text-xs text-muted-foreground">You</span>
</div>
)}
{e.entryRatings?.tmdb_rating != null &&
e.entryRatings.tmdb_rating > 0 && (
<div className="flex items-center gap-1">
<span className="text-sm font-medium">
{e.entryRatings.tmdb_rating.toFixed(1)}
</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>
)}
</div>
{/* Actions */}
<div className="flex items-center gap-2 pt-2">
<Button
variant={e.favorit ? 'default' : 'outline'}
size="sm"
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>
{/* Storyline */}
{e.storyline && (
<div className="space-y-2">
<h3 className="text-lg font-semibold">Overview</h3>
<p className="text-sm text-muted-foreground leading-relaxed">
{e.storyline}
</p>
</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 */}
{showSettings && (
<EntrySettingsDialog
open={showSettings}
onOpenChange={setShowSettings}
entry={e}
/>
)}
{showSeenDialog && (
<EntrySeenDialog
open={showSeenDialog}
onOpenChange={setShowSeenDialog}
entry={e}
seasons={seasons}
mode="add"
/>
)}
{showMediaDialog && (
<EntryMediaDialog
open={showMediaDialog}
onOpenChange={setShowMediaDialog}
entryId={e.id}
medias={e.medias || []}
/>
)}
{showCollectionDialog && (
<AddEntryToCollectionDialog
open={showCollectionDialog}
onOpenChange={setShowCollectionDialog}
entryId={e.id}
/>
)}
</div>
);
}
function EntryDetailsSkeleton() {
return (
<div className="space-y-8">
<div className="flex gap-6">
<Skeleton className="h-72 w-48 shrink-0 rounded-lg" />
<div className="flex-1 space-y-4">
<Skeleton className="h-8 w-64" />
<Skeleton className="h-4 w-40" />
<Skeleton className="h-4 w-80" />
<div className="flex gap-2">
<Skeleton className="h-8 w-24" />
<Skeleton className="h-8 w-32" />
</div>
</div>
</div>
</div>
);
}