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 (
Your AI-powered literary companion that learns your taste and finds books you'll love
{/* Enhanced Search Bar */}Three powerful recommendation methods working together
Analyzes reading patterns from millions of users to find readers with similar tastes and recommend their favorite books
Examines book attributes like genre, author, publisher, and keywords to find similar titles you'll enjoy
Combines both methods to leverage the strengths of user patterns and content analysis for superior recommendations
Discover what readers are loving
Start your journey with BookMind today. Our intelligent algorithm learns from your preferences to deliver personalized recommendations you'll love.