tahamajs/IE / Projects /front /src /components /trust /ResearcherIdentityCard.tsx
tahamajs's picture
download
raw
4.17 kB
// src/components/trust/ResearcherIdentityCard.tsx
import { useState, useEffect } from "react";
import api from "@/lib/api";
import type { ResearcherIdentity } from "@/types/trust";
import { CheckCircle2, ExternalLink, RefreshCw, Github, BookOpen } from "lucide-react";
import { motion } from "framer-motion";
interface ResearcherIdentityCardProps {
username: string;
}
export function ResearcherIdentityCard({ username }: ResearcherIdentityCardProps) {
const [identity, setIdentity] = useState<ResearcherIdentity | null>(null);
const [loading, setLoading] = useState(true);
useEffect(() => {
api.get(`/users/${username}/identity`)
.then(res => setIdentity(res.data))
.catch(() => {})
.finally(() => setLoading(false));
}, [username]);
if (loading) {
return <div className="glass rounded-2xl p-5 animate-pulse space-y-3"><div className="h-4 w-32 bg-gray-200 dark:bg-gray-700 rounded"/><div className="h-3 w-48 bg-gray-200 dark:bg-gray-700 rounded"/></div>;
}
if (!identity) return null;
return (
<div className="glass rounded-2xl border border-white/20 dark:border-white/10 p-5">
<h3 className="font-bold text-lg flex items-center gap-2 mb-4">
<CheckCircle2 className="w-5 h-5 text-green-500" />
Verified Identity
</h3>
<div className="space-y-3">
{/* ORCID */}
<div className="flex items-center justify-between p-3 rounded-xl bg-white/30 dark:bg-white/5">
<div className="flex items-center gap-3">
<BookOpen className="w-5 h-5 text-green-600" />
<div>
<p className="text-sm font-semibold">ORCID</p>
<a href={`https://orcid.org/${identity.orcid}`} target="_blank" className="text-xs text-primary hover:underline flex items-center gap-1">
{identity.orcid} <ExternalLink className="w-3 h-3" />
</a>
</div>
</div>
<CheckCircle2 className="w-4 h-4 text-green-500" />
</div>
{/* GitHub */}
{identity.githubUsername && (
<div className="flex items-center justify-between p-3 rounded-xl bg-white/30 dark:bg-white/5">
<div className="flex items-center gap-3">
<Github className="w-5 h-5" />
<div>
<p className="text-sm font-semibold">GitHub</p>
<a href={`https://github.com/${identity.githubUsername}`} target="_blank" className="text-xs text-primary hover:underline">
@{identity.githubUsername}
</a>
</div>
</div>
<CheckCircle2 className="w-4 h-4 text-green-500" />
</div>
)}
{/* Hugging Face */}
{identity.huggingFaceUsername && (
<div className="flex items-center justify-between p-3 rounded-xl bg-white/30 dark:bg-white/5">
<div className="flex items-center gap-3">
<span className="text-lg">🤗</span>
<div>
<p className="text-sm font-semibold">Hugging Face</p>
<a href={`https://huggingface.co/${identity.huggingFaceUsername}`} target="_blank" className="text-xs text-primary hover:underline">
@{identity.huggingFaceUsername}
</a>
</div>
</div>
<CheckCircle2 className="w-4 h-4 text-green-500" />
</div>
)}
</div>
{/* Stats */}
<div className="grid grid-cols-3 gap-2 mt-4">
{[
{ label: "Publications", value: identity.publications },
{ label: "Citations", value: identity.citations },
{ label: "h-index", value: identity.hIndex },
].map(s => (
<div key={s.label} className="text-center p-2 rounded-xl bg-white/30 dark:bg-white/5">
<p className="text-lg font-extrabold text-primary">{s.value}</p>
<p className="text-[10px] text-gray-500">{s.label}</p>
</div>
))}
</div>
<p className="text-[10px] text-gray-400 mt-3 text-center">
Last synced: {new Date(identity.lastSynced).toLocaleDateString()}
</p>
</div>
);
}

Xet Storage Details

Size:
4.17 kB
·
Xet hash:
e07942de7f75bdeb9b3e50e68083adb8488fb9eeec93b7a95c1976049992c0ae

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.