import React, { useState, useEffect } from 'react'; import { Heart, X, Trash2 } from 'lucide-react'; import BookCard from '../components/BookCard'; const FavoritesView = ({ onRecommend, onViewDetails, onBack }) => { const [favorites, setFavorites] = useState([]); useEffect(() => { const saved = JSON.parse(localStorage.getItem('bookFavorites') || '[]'); setFavorites(saved); }, []); const removeFavorite = (title) => { const updated = favorites.filter(book => book.title !== title); setFavorites(updated); localStorage.setItem('bookFavorites', JSON.stringify(updated)); }; const clearAllFavorites = () => { if (window.confirm('Are you sure you want to clear all favorites?')) { setFavorites([]); localStorage.setItem('bookFavorites', JSON.stringify([])); } }; return (
{/* Header */}

Your Favorites

{favorites.length} book{favorites.length !== 1 ? 's' : ''} saved

{favorites.length > 0 && ( )}
{/* Content */}
{favorites.length === 0 ? (

No Favorites Yet

Click the heart icon on any book to add it to your favorites and find them all here.

) : (
{favorites.map((book, i) => (
))}
)}
); }; export default FavoritesView;