import { useState } from "react"; import { useParams, Link } from "react-router-dom"; import { Heart, ArrowLeft, Tag, User, Calendar, Share, Flag, } from "lucide-react"; const ProductDetail = () => { const { id } = useParams(); const [isFavorite, setIsFavorite] = useState(false); const [showContactForm, setShowContactForm] = useState(false); const [message, setMessage] = useState(""); const [currentImage, setCurrentImage] = useState(0); // Sample data for demonstration const product = [ { id: 0, title: "Dell XPS 13 Laptop - 2023 Model", price: 850, shortDescription: "Dell XPS 13 laptop in excellent condition. Intel Core i7, 16GB RAM, 512GB SSD. Includes charger and original box.", description: "Selling my Dell XPS 13 laptop. Only 6 months old and in excellent condition. Intel Core i7 processor, 16GB RAM, 512GB SSD. Battery life is still excellent (around 10 hours of regular use). Comes with original charger and box. Selling because I'm upgrading to a MacBook for design work.\n\nSpecs:\n- Intel Core i7 11th Gen\n- 16GB RAM\n- 512GB NVMe SSD\n- 13.4\" FHD+ Display (1920x1200)\n- Windows 11 Pro\n- Backlit Keyboard\n- Thunderbolt 4 ports", condition: "Like New", category: "Electronics, Electronics, Electronics, Electronics , Electronics , Electronics, Electronicss", datePosted: "2023-03-02", images: [ "/image1.avif", "/image2.avif", "/image3.avif", "/image3.avif", "/image3.avif", ], seller: { name: "Michael T.", rating: 4.8, memberSince: "January 2022", avatar: "/Profile.jpg", }, }, ]; console.log(product[id]); const toggleFavorite = () => { setIsFavorite(!isFavorite); }; const handleSendMessage = (e) => { e.preventDefault(); // TODO: this would send the message to the seller console.log("Message sent:", message); setMessage(""); setShowContactForm(false); // Show confirmation or success message alert("Message sent to seller!"); }; // Function to split description into paragraphs const formatDescription = (text) => { return text.split("\n\n").map((paragraph, index) => (
{paragraph.split("\n").map((line, i) => (
{line}
{i < paragraph.split("\n").length - 1 &&
}
))}
{product[id].shortDescription}
Member since {product[id].seller.memberSince}