import Link from 'next/link'; import { Star, Download, Shield, CheckCircle, Clock, RefreshCw, Sparkles } 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; reviewStatus?: string | null; aiScore?: number | null; latestAiScore?: number | 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; // AI review score badge (only for reviewed skills with score >= 50) const getAiScoreBadge = () => { const rs = skill.reviewStatus; if (!rs || rs === 'unreviewed' || rs === 'auto-scored') return null; const score = skill.aiScore ?? skill.latestAiScore; if (!score || score < 50) return null; const color = score >= 75 ? 'text-success bg-success/10 border-success/20' : 'text-gold bg-gold/10 border-gold/20'; return { score, color }; }; const aiScoreBadge = getAiScoreBadge(); 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: AI Score + Stars + Downloads + Rating */}
{aiScoreBadge && ( {aiScoreBadge.score} )} {formatCompactNumber(skill.githubStars || 0, locale)} {formatCompactNumber(skill.downloadCount || 0, locale)} {showRating && ( {skill.rating?.toFixed(1)} ({skill.ratingCount}) )}
{/* Author */}
@{skill.githubOwner}
); }