"use client"; import { useMemo, useState } from "react"; import Image from "next/image"; import Link from "next/link"; import { useCart } from "@/contexts/CartContext"; import { ProductSocialBlock } from "@/components/shop/ProductSocialBlock"; import { SHOP_PRODUCTS, type ShopProduct } from "@/lib/shopCatalog"; import { getProductSocialMetrics } from "@/lib/shopProductSocial"; interface ProductCardProps { id: string; name: string; description: string; price: number; currency: "BTC" | "ETH" | "USD" | "XMR"; category: string; imageUrl: string; sellerHandle: string; sellerSlug: string; limited?: boolean; glowColor?: string; /** When set, add-to-cart uses this row; otherwise looks up by `id` in SHOP_PRODUCTS */ shopProduct?: ShopProduct; } const ProductCard = ({ id, name, description, price, currency, category, imageUrl, sellerHandle, sellerSlug, limited = false, glowColor: _glow = "neon-cyan", shopProduct, }: ProductCardProps) => { void _glow; const [isHovered, setIsHovered] = useState(false); const [isFavorite, setIsFavorite] = useState(false); const [justAdded, setJustAdded] = useState(false); const { addToCart, hydrated: cartReady } = useCart(); const metrics = useMemo(() => getProductSocialMetrics(id), [id]); const currencySymbols = { BTC: "₿", ETH: "Ξ", USD: "$", XMR: "⏣", }; const formatPrice = (p: number) => { if (currency === "BTC") return p.toFixed(6); if (currency === "ETH") return p.toFixed(4); if (currency === "XMR") return p.toFixed(3); return p.toFixed(2); }; const resolveProduct = (): ShopProduct | undefined => shopProduct ?? SHOP_PRODUCTS.find((x) => x.id === id); const handleAddToCart = () => { const p = resolveProduct(); if (!p) return; addToCart(p, 1); setJustAdded(true); window.setTimeout(() => setJustAdded(false), 1800); }; return (
Seller:{" "} {sellerHandle}
{description}
Verified chatter
{metrics.testimonials.slice(0, 1).map((t, i) => (“{t.text}” — @{t.handle} · ★{t.rating} · {t.daysAgo}d ago
))}