import React, { useState, useEffect } from 'react'; import { Search, Sparkles, Sidebar as Shuffle, Users, BookOpen, Heart, Zap, TrendingUp, Star } from 'lucide-react'; import BookCard from '../components/BookCard'; import SearchHistory from '../components/SearchHistory'; const HomeView = ({ popularBooks, onRecommend, onViewDetails, onViewFavorites }) => { const [query, setQuery] = useState(''); const [results, setResults] = useState([]); const [showButtons, setShowButtons] = useState(false); const [favCount, setFavCount] = useState(0); const [showHistory, setShowHistory] = useState(false); useEffect(() => { const favorites = JSON.parse(localStorage.getItem('bookFavorites') || '[]'); setFavCount(favorites.length); }, []); const handleSearchChange = async (e) => { const val = e.target.value; setQuery(val); if (val.length >= 2) { try { const resp = await fetch(`/api/search_books?query=${encodeURIComponent(val)}`); const data = await resp.json(); setResults(data); } catch (err) { console.error(err); } } else { setResults([]); setShowButtons(false); } }; const handleSelect = (title) => { setQuery(title); setResults([]); setShowButtons(true); setShowHistory(false); // Add to search history const history = JSON.parse(localStorage.getItem('searchHistory') || '[]'); const book = results.find(b => b.title === title) || { title }; const filtered = history.filter(h => h.title !== title); filtered.unshift(book); localStorage.setItem('searchHistory', JSON.stringify(filtered.slice(0, 10))); // Keep last 10 }; return (
{/* Premium Hero Section */}
{/* Favorites Button */} {/* Decorative Elements */}
Smart Book Discovery

BookMind

Your AI-powered literary companion that learns your taste and finds books you'll love

{/* Enhanced Search Bar */}
e.key === 'Enter' && setShowButtons(true)} />
{/* Search Results Dropdown */} {results.length > 0 && (
{results.map((book, i) => ( ))}
)} {/* Search History */} {showHistory && ( setShowHistory(false)} /> )} {/* Recommendation Buttons */} {showButtons && (
)}
{/* Features Section - Enhanced */}

How BookMind Works

Three powerful recommendation methods working together

{/* Collaborative Filtering */}

Collaborative Filtering

Analyzes reading patterns from millions of users to find readers with similar tastes and recommend their favorite books

User-Based Learning
{/* Content-Based */}

Content-Based Filtering

Examines book attributes like genre, author, publisher, and keywords to find similar titles you'll enjoy

Content Analysis
{/* Hybrid */}

Hybrid Model

Combines both methods to leverage the strengths of user patterns and content analysis for superior recommendations

Best of Both Worlds
{/* Trending Books Section - Enhanced */}

Trending Now

Discover what readers are loving

Popular Picks
{popularBooks.map((book, i) => ( ))}
{/* CTA Section */}

Find Your Next Favorite Book

Start your journey with BookMind today. Our intelligent algorithm learns from your preferences to deliver personalized recommendations you'll love.

); }; export default HomeView;