import { Link } from 'react-router-dom'
import type { Repository } from '../../types/api'
interface RepoCardProps {
repo: Repository
}
export function RepoCard({ repo }: RepoCardProps) {
const ago = timeAgo(repo.updatedAt)
return (
{/* Icon */}
{/* Info */}
{repo.name}
{repo.isPrivate && (
Private
)}
{repo.description && (
{repo.description}
)}
Updated {ago} ยท {repo.defaultBranch}
)
}
function timeAgo(iso: string): string {
const diff = Date.now() - new Date(iso).getTime()
const m = Math.floor(diff / 60000)
if (m < 1) return 'just now'
if (m < 60) return `${m}m ago`
const h = Math.floor(m / 60)
if (h < 24) return `${h}h ago`
const d = Math.floor(h / 24)
if (d < 30) return `${d}d ago`
return new Date(iso).toLocaleDateString()
}