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 */}
e.stopPropagation()} > {/* Close Button */} {/* Modal Content */}
{/* Header with Book Image and Info */}
{/* Book Cover */}
{book.title}
{/* Book Details */}

{book.title}

{book.author}

{/* Rating Stars */}
{[1, 2, 3, 4, 5].map((star) => ( ))}
{rating > 0 ? `You rated: ${rating}/5` : 'Rate this book'}
{/* Book Metadata */}
{book.year && (
{book.year}
)} {book.publisher && (
{book.publisher}
)}
{/* Action Buttons */}
{/* Description Section */}

About This Book

{book.description || 'No description available for this book.'}

{/* Recommendation Methods */}

Get Recommendations

{/* Close Button */}
); }; export default BookDetailsModal;