import { Badge } from '@thedaviddias/design-system/badge' import { logger } from '@thedaviddias/logging' import { Bug, FileText, GitPullRequest, User } from 'lucide-react' import Link from 'next/link' import { getContributionTypeLabel, getUserContributions } from '@/lib/github-contributions' import { hashSensitiveData } from '@/lib/server-crypto' interface ProfileContributionsProps { githubUsername: string | null isOwnProfile: boolean username: string | null } /** * ProfileContributions component that displays GitHub contributions for a user * * @param props - Component props * @param props.githubUsername - GitHub username to fetch contributions for * @param props.isOwnProfile - Whether this is the current user's own profile * @param props.username - Display username for messaging * @returns React component displaying contributions or empty state */ export async function ProfileContributions({ githubUsername, isOwnProfile, username }: ProfileContributionsProps) { // Get GitHub contributions for any valid GitHub username let contributions if (githubUsername) { logger.info('ProfileContributions: Fetching contributions', { data: { usernameHash: hashSensitiveData(githubUsername) }, tags: { type: 'component', component: 'contributions' } }) try { contributions = await getUserContributions(githubUsername) logger.info('ProfileContributions: Contributions fetched successfully', { data: { usernameHash: hashSensitiveData(githubUsername), total: contributions.total, pullRequests: contributions.pullRequests, issues: contributions.issues, commits: contributions.commits }, tags: { type: 'component', component: 'contributions' } }) } catch (error) { logger.error('ProfileContributions: Error fetching contributions', { data: { usernameHash: hashSensitiveData(githubUsername), error: error instanceof Error ? error.message : 'Unknown error' }, tags: { type: 'component', component: 'contributions', error: 'fetch-failed' } }) contributions = { total: 0, pullRequests: 0, issues: 0, commits: 0, contributions: [] } } } else { contributions = { total: 0, pullRequests: 0, issues: 0, commits: 0, contributions: [] } } return (

Recent Contributions

{contributions.total > 0 && {contributions.total} total}
{contributions.contributions.length > 0 ? (
{contributions.contributions.map((contribution, index) => (
{contribution.type === 'pull_request' && ( )} {contribution.type === 'issue' && } {contribution.type === 'commit' && }
{getContributionTypeLabel(contribution.type)} {contribution.state && ( {contribution.merged ? 'merged' : contribution.state} )}
{contribution.title}

{new Date(contribution.created_at).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })}

))}
) : (

No contributions found

{githubUsername ? 'No contributions to llms-txt-hub yet' : isOwnProfile ? 'Sign in with GitHub to display your contributions' : 'GitHub account not verified'}

{isOwnProfile && !githubUsername && username && (

Note: Contributions only show for GitHub OAuth verified accounts

)}
)}
) }