import React from "react"; import { Card, CardContent } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { HubModel } from "@/lib/jobsApi"; import { ExternalLink, Lock, Upload } from "lucide-react"; interface Props { model: HubModel; } function relativeTime(iso: string | null): string { if (!iso) return "—"; const t = Date.parse(iso); if (Number.isNaN(t)) return "—"; const diff = Math.max(0, (Date.now() - t) / 1000); if (diff < 60) return `${Math.floor(diff)}s ago`; if (diff < 3600) return `${Math.floor(diff / 60)}m ago`; if (diff < 86400) return `${Math.floor(diff / 3600)}h ago`; return `${Math.floor(diff / 86400)}d ago`; } const HubModelCard: React.FC = ({ model }) => { const url = `https://huggingface.co/${model.repo_id}`; const shortName = model.repo_id.includes("/") ? model.repo_id.split("/").slice(1).join("/") : model.repo_id; return ( window.open(url, "_blank", "noopener,noreferrer")} className="bg-slate-800/50 border-slate-700 rounded-xl cursor-pointer hover:border-slate-500 transition-colors" >
Uploaded
{model.private ? ( ) : null} {shortName}
{model.repo_id} · updated {relativeTime(model.last_modified)}
); }; export default HubModelCard;