'use client'; import { useState } from 'react'; import Link from 'next/link'; import { Product } from '@/mock/product'; interface ProductCardProps { product: Product; onAdd?: () => void; added?: boolean; } function getRestrictionFlags(restrictions?: Product['restrictions']): string[] { const flags: string[] = []; if (restrictions?.nfa) flags.push('NFA'); if (restrictions?.sbr) flags.push('SBR'); if (restrictions?.suppressor) flags.push('SUPPRESSOR'); if (restrictions?.stateRestrictions && restrictions.stateRestrictions.length > 0) flags.push('STATE_RESTRICTIONS'); return flags; } export default function ProductCard({ product, onAdd, added }: 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)} /> {getRestrictionFlags(product.restrictions).length > 0 && (
{getRestrictionFlags(product.restrictions).map((restriction) => ( ))}
)}

{product.name}

{product.description}

{product.brand.name} ${lowestPrice.toFixed(2)}
{product.category.name} View Details {onAdd && ( )}
); }