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,78 @@
|
||||
import { useTrendingMovies, useTrendingTv, usePopularMovies, usePopularTv, useTmdbSearch } from '@/hooks/useTmdb';
|
||||
import { useLibrary } from '@/hooks/useEntries';
|
||||
import { TrendingGrid } from '@/components/entries/TrendingGrid';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { useState } from 'react';
|
||||
import { Search } from 'lucide-react';
|
||||
import { EntryCard } from '@/components/entries/EntryCard';
|
||||
|
||||
export function HomePage() {
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
|
||||
// Pre-load library
|
||||
useLibrary();
|
||||
|
||||
const trendingMovies = useTrendingMovies();
|
||||
const trendingTv = useTrendingTv();
|
||||
const popularMovies = usePopularMovies();
|
||||
const popularTv = usePopularTv();
|
||||
const searchResults = useTmdbSearch(searchQuery);
|
||||
|
||||
const trendingMovieEntries = trendingMovies.data?.pages.flatMap((p) => p.results) ?? [];
|
||||
const trendingTvEntries = trendingTv.data?.pages.flatMap((p) => p.results) ?? [];
|
||||
const popularMovieEntries = popularMovies.data?.pages.flatMap((p) => p.results) ?? [];
|
||||
const popularTvEntries = popularTv.data?.pages.flatMap((p) => p.results) ?? [];
|
||||
const searchEntries = searchResults.data?.pages.flatMap((p) => p.results) ?? [];
|
||||
|
||||
const isSearching = searchQuery.length > 0;
|
||||
|
||||
return (
|
||||
<div className="space-y-8">
|
||||
{/* Search */}
|
||||
<div className="relative max-w-md">
|
||||
<Search className="absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
|
||||
<Input
|
||||
placeholder="Search movies & TV shows..."
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
className="pl-10"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{isSearching ? (
|
||||
<div className="space-y-4">
|
||||
<h2 className="text-xl font-semibold">
|
||||
Search Results for "{searchQuery}"
|
||||
</h2>
|
||||
{searchEntries.length === 0 && !searchResults.isLoading ? (
|
||||
<p className="text-muted-foreground">No results found.</p>
|
||||
) : (
|
||||
<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">
|
||||
{searchEntries.map((entry) => (
|
||||
<EntryCard key={entry.id} tmdbEntry={entry} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
<TrendingGrid
|
||||
title="Trending"
|
||||
movieEntries={trendingMovieEntries}
|
||||
tvEntries={trendingTvEntries}
|
||||
isLoading={trendingMovies.isLoading || trendingTv.isLoading}
|
||||
moreLink="/library"
|
||||
/>
|
||||
|
||||
<TrendingGrid
|
||||
title="Popular"
|
||||
movieEntries={popularMovieEntries}
|
||||
tvEntries={popularTvEntries}
|
||||
isLoading={popularMovies.isLoading || popularTv.isLoading}
|
||||
moreLink="/library"
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user