'use client'; import { useState } from 'react'; interface ProductCardProps { product: { id: string; name: string; description: string; image_url: string; brand: { name: string }; category: { name: string }; restrictions: string[]; offers: Array<{ price: number; vendor: { name: string } }>; }; } export default function ProductCard({ product }: ProductCardProps) { const [imageError, setImageError] = useState(false); const lowestPrice = Math.min(...product.offers.map(offer => offer.price)); // Restriction badge component const RestrictionBadge = ({ restriction }: { restriction: string }) => { const restrictionConfig = { NFA: { label: 'NFA', color: 'badge-error', icon: 'πŸ”’', tooltip: 'National Firearms Act - Requires special registration' }, SBR: { label: 'SBR', color: 'badge-warning', icon: 'πŸ“', tooltip: 'Short Barrel Rifle - Requires NFA registration' }, SUPPRESSOR: { label: 'Suppressor', color: 'badge-secondary', icon: 'πŸ”‡', tooltip: 'Sound Suppressor - Requires NFA registration' }, FFL_REQUIRED: { label: 'FFL', color: 'badge-info', icon: 'πŸͺ', tooltip: 'Federal Firearms License required for purchase' }, STATE_RESTRICTIONS: { label: 'State', color: 'badge-warning', icon: 'πŸ—ΊοΈ', tooltip: 'State-specific restrictions may apply' }, HIGH_CAPACITY: { label: 'High Cap', color: 'badge-accent', icon: 'πŸ₯', tooltip: 'High capacity magazine - check local laws' }, SILENCERSHOP_PARTNER: { label: 'SilencerShop', color: 'badge-success', icon: '🀝', tooltip: 'Available through SilencerShop partnership' } }; const config = restrictionConfig[restriction as keyof typeof restrictionConfig]; if (!config) return null; return (
{config.icon} {config.label}
); }; return (
{product.name} setImageError(true)} /> {product.restrictions && product.restrictions.length > 0 && (
{product.restrictions.map((restriction) => ( ))}
)}

{product.name}

{product.description}

{product.brand.name} ${lowestPrice.toFixed(2)}
{product.category.name}
); }