'use client'; import { ReactNode } from 'react'; import { ExternalLink } from 'lucide-react'; import { cn } from '@/lib/utils'; export interface UnifiedCardProps { type: 'product' | 'video' | 'profile' | 'promo' | 'article'; image?: string; imageAlt?: string; title: string; subtitle?: string; badge?: { text: string; variant: 'success' | 'warning' | 'error' | 'info' | 'default'; }; meta?: string[]; action?: { label: string; url: string; variant?: 'primary' | 'secondary'; }; secondaryAction?: { label: string; onClick: () => void; }; children?: ReactNode; className?: string; href?: string; compact?: boolean; horizontal?: boolean; } const badgeVariants = { success: 'bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400', warning: 'bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400', error: 'bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400', info: 'bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400', default: 'bg-light-200 text-black/70 dark:bg-dark-200 dark:text-white/70', }; const PLACEHOLDER_IMAGE = 'data:image/svg+xml,' + encodeURIComponent( 'No Image' ); export function UnifiedCard({ type, image, imageAlt, title, subtitle, badge, meta, action, secondaryAction, children, className, href, compact = false, horizontal = false, }: UnifiedCardProps) { const CardWrapper = href ? 'a' : 'div'; const wrapperProps = href ? { href, target: '_blank', rel: 'noopener noreferrer' } : {}; return ( {image && (
{imageAlt { (e.target as HTMLImageElement).src = PLACEHOLDER_IMAGE; }} /> {badge && ( {badge.text} )}
)}
{!image && badge && ( {badge.text} )}

{title}

{subtitle && (

{subtitle}

)} {meta && meta.length > 0 && (
{meta.map((item, i) => ( {item} ))}
)} {children}
{(action || secondaryAction) && !compact && (
{action && ( e.stopPropagation()} className={cn( 'flex items-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium transition-colors', action.variant === 'secondary' ? 'bg-light-100 dark:bg-dark-100 text-black/70 dark:text-white/70 hover:bg-light-200 dark:hover:bg-dark-200' : 'bg-[#EA580C] text-white hover:bg-[#EA580C]/90' )} > {action.label} )} {secondaryAction && ( )}
)}
{href && (
)}
); } export default UnifiedCard;