import Link from 'next/link'; import { Star, Download, Shield, CheckCircle, Clock, RefreshCw } from 'lucide-react'; import { formatCompactNumber } from '@/lib/format-number'; const FORMAT_BADGE_LABELS: Record = { 'agents.md': 'AGENTS.md', 'cursorrules': '.cursorrules', 'windsurfrules': '.windsurfrules', 'copilot-instructions': 'Copilot', }; interface SkillCardProps { skill: { id: string; name: string; description: string | null; githubOwner: string; githubStars: number | null; downloadCount: number | null; rating: number | null; ratingCount: number | null; securityStatus: string | null; isVerified: boolean | null; sourceFormat?: string | null; createdAt?: Date | string | null; updatedAt?: Date | string | null; }; locale: string; /** Show time badge (for New Skills page) */ showTimeBadge?: 'created' | 'updated' | null; /** Format time as "X days ago" */ formatTimeAgo?: (date: Date | string | null, locale: string) => string; } export function SkillCard({ skill, locale, showTimeBadge, formatTimeAgo }: SkillCardProps) { const getSecurityColor = (status: string | null) => { switch (status) { case 'pass': return 'text-success'; case 'warning': return 'text-warning'; case 'fail': return 'text-error'; default: return 'text-text-muted'; } }; const getSecurityLabel = (status: string | null) => { switch (status) { case 'pass': return '✓'; case 'warning': return '⚠'; case 'fail': return '✕'; default: return '-'; } }; const showRating = (skill.ratingCount ?? 0) >= 3; return ( {/* Time Badge (for New Skills page) */} {showTimeBadge && formatTimeAgo && (
{showTimeBadge === 'created' ? ( {formatTimeAgo(skill.createdAt ?? null, locale)} ) : ( {formatTimeAgo(skill.updatedAt ?? null, locale)} )}
)} {/* Header: Name + Verified + Format Badge + Security */}

{skill.name}

{skill.isVerified && ( )} {skill.sourceFormat && skill.sourceFormat !== 'skill.md' && FORMAT_BADGE_LABELS[skill.sourceFormat] && ( {FORMAT_BADGE_LABELS[skill.sourceFormat]} )}
{getSecurityLabel(skill.securityStatus)}
{/* Description */}

{skill.description}

{/* Metadata Row: Stars + Downloads + Rating */}
{formatCompactNumber(skill.githubStars || 0, locale)} {formatCompactNumber(skill.downloadCount || 0, locale)} {showRating && ( {skill.rating?.toFixed(1)} ({skill.ratingCount}) )}
{/* Author */}
@{skill.githubOwner}
); }