import React from 'react'; import { Button } from '~/components/ui/Button'; import type { GitHubStats } from '~/types/GitHub'; interface StatsDisplayProps { stats: GitHubStats; onRefresh?: () => void; isRefreshing?: boolean; } export function StatsDisplay({ stats, onRefresh, isRefreshing }: StatsDisplayProps) { // Calculate top languages for display const topLanguages = Object.entries(stats.languages || {}) .sort(([, a], [, b]) => b - a) .slice(0, 5); return (
{/* Repository Stats */}
Repository Stats
{[ { label: 'Public Repos', value: stats.publicRepos || 0, }, { label: 'Private Repos', value: stats.privateRepos || 0, }, ].map((stat, index) => (
{stat.label} {stat.value.toLocaleString()}
))}
{/* Contribution Stats */}
Contribution Stats
{[ { label: 'Stars', value: stats.totalStars || stats.stars || 0, icon: 'i-ph:star', iconColor: 'text-bolt-elements-icon-warning', }, { label: 'Forks', value: stats.totalForks || stats.forks || 0, icon: 'i-ph:git-fork', iconColor: 'text-bolt-elements-icon-info', }, { label: 'Followers', value: stats.followers || 0, icon: 'i-ph:users', iconColor: 'text-bolt-elements-icon-success', }, ].map((stat, index) => (
{stat.label}
{stat.value.toLocaleString()}
))}
{/* Gist Stats */}
Gist Stats
{[ { label: 'Public Gists', value: stats.publicGists || 0, icon: 'i-ph:note', }, { label: 'Total Gists', value: stats.totalGists || 0, icon: 'i-ph:note-blank', }, ].map((stat, index) => (
{stat.label}
{stat.value.toLocaleString()}
))}
{/* Top Languages */} {topLanguages.length > 0 && (
Top Languages
{topLanguages.map(([language, count]) => (
{language} {count} repositories
))}
)} {/* Recent Activity */} {stats.recentActivity && stats.recentActivity.length > 0 && (
Recent Activity
{stats.recentActivity.slice(0, 3).map((activity) => (
{activity.type.replace('Event', '')} in {activity.repo.name} {new Date(activity.created_at).toLocaleDateString()}
))}
)}
Last updated: {new Date(stats.lastUpdated).toLocaleString()} {onRefresh && ( )}
); }