Implemented the new react version of the frontend
This commit is contained in:
1 parent
236e6e06fb
commit
ffe7e52527
65 files changed
+5228
-177
No files matched your search
@@ -0,0 +1,114 @@
|
||||
import { useMemo } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { useLibrary } from '@/hooks/useEntries';
|
||||
import { useStatistics } from '@/hooks/useStatistics';
|
||||
import { useLibraryEntries } from '@/stores/useLibraryStore';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { Film, Tv, Heart, ListVideo, Clock } from 'lucide-react';
|
||||
import { formatRuntime, getPosterUrl } from '@/lib/media-utils';
|
||||
|
||||
export function DashboardPage() {
|
||||
useLibrary();
|
||||
const { data: stats, isLoading: statsLoading } = useStatistics();
|
||||
const allEntries = useLibraryEntries();
|
||||
|
||||
const movies = useMemo(() => allEntries.filter((e) => !e.is_tvseries && !e.watchlist), [allEntries]);
|
||||
const tvSeries = useMemo(() => allEntries.filter((e) => e.is_tvseries && !e.watchlist), [allEntries]);
|
||||
const favorites = useMemo(() => allEntries.filter((e) => e.favorit && !e.watchlist), [allEntries]);
|
||||
const watchlist = useMemo(() => allEntries.filter((e) => e.watchlist), [allEntries]);
|
||||
|
||||
const statCards = [
|
||||
{
|
||||
title: 'Movies',
|
||||
value: movies.length,
|
||||
icon: Film,
|
||||
color: 'text-blue-500',
|
||||
},
|
||||
{
|
||||
title: 'TV Series',
|
||||
value: tvSeries.length,
|
||||
icon: Tv,
|
||||
color: 'text-green-500',
|
||||
},
|
||||
{
|
||||
title: 'Favorites',
|
||||
value: favorites.length,
|
||||
icon: Heart,
|
||||
color: 'text-red-500',
|
||||
},
|
||||
{
|
||||
title: 'Watchlist',
|
||||
value: watchlist.length,
|
||||
icon: ListVideo,
|
||||
color: 'text-purple-500',
|
||||
},
|
||||
{
|
||||
title: 'Watch Time',
|
||||
value: stats?.totalWatchTime
|
||||
? formatRuntime(stats.totalWatchTime)
|
||||
: '0h',
|
||||
icon: Clock,
|
||||
color: 'text-orange-500',
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="space-y-8">
|
||||
<h1 className="text-2xl font-bold">Dashboard</h1>
|
||||
|
||||
{/* Stats Grid */}
|
||||
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5">
|
||||
{statCards.map((stat) => (
|
||||
<Card key={stat.title}>
|
||||
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
||||
<CardTitle className="text-sm font-medium text-muted-foreground">
|
||||
{stat.title}
|
||||
</CardTitle>
|
||||
<stat.icon className={`h-5 w-5 ${stat.color}`} />
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{statsLoading ? (
|
||||
<Skeleton className="h-8 w-16" />
|
||||
) : (
|
||||
<p className="text-2xl font-bold">{stat.value}</p>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Recently Watched */}
|
||||
<div className="space-y-4">
|
||||
<h2 className="text-lg font-semibold">Recently Watched</h2>
|
||||
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 2xl:grid-cols-7">
|
||||
{allEntries
|
||||
.filter((e) => e.date_last_seen)
|
||||
.sort(
|
||||
(a, b) =>
|
||||
new Date(b.date_last_seen!).getTime() -
|
||||
new Date(a.date_last_seen!).getTime()
|
||||
)
|
||||
.slice(0, 14)
|
||||
.map((entry) => (
|
||||
<Link
|
||||
key={entry.id}
|
||||
to={`/entry/${entry.id}`}
|
||||
className="group transition-transform hover:scale-[1.02]"
|
||||
>
|
||||
<img
|
||||
src={getPosterUrl(entry)}
|
||||
alt={entry.title}
|
||||
className="aspect-[2/3] w-full rounded-lg object-cover"
|
||||
loading="lazy"
|
||||
/>
|
||||
<p className="mt-1 text-xs font-medium truncate">
|
||||
{entry.title}
|
||||
</p>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user