import React, { useState } from 'react'; import { X, Star, Heart, Share2, Calendar, Building, User, BookOpen, TrendingUp } from 'lucide-react'; const BookDetailsModal = ({ book, onClose, onRecommend }) => { const [isFavorite, setIsFavorite] = useState(false); const [rating, setRating] = useState(0); const [hoverRating, setHoverRating] = useState(0); const handleAddToFavorites = () => { setIsFavorite(!isFavorite); // Save to localStorage const favorites = JSON.parse(localStorage.getItem('bookFavorites') || '[]'); if (!isFavorite) { favorites.push(book); localStorage.setItem('bookFavorites', JSON.stringify(favorites)); } else { const filtered = favorites.filter(fav => fav.title !== book.title); localStorage.setItem('bookFavorites', JSON.stringify(filtered)); } }; const handleShare = () => { const shareText = `Check out "${book.title}" by ${book.author} on BookMind! 📚`; if (navigator.share) { navigator.share({ title: book.title, text: shareText, url: window.location.href, }); } else { // Fallback: Copy to clipboard navigator.clipboard.writeText(shareText); alert('Recommendation copied to clipboard!'); } }; const handleRating = (value) => { setRating(value); // Save rating to localStorage const ratings = JSON.parse(localStorage.getItem('bookRatings') || '{}'); ratings[book.title] = value; localStorage.setItem('bookRatings', JSON.stringify(ratings)); }; if (!book) return null; return ( <> {/* Backdrop */}
{/* Modal */}
{book.description || 'No description available for this book.'}