Apply profile enhancements precisely
cgen-0b31e2ae1451424ca79030f34e837c58
This commit is contained in:
parent
b5fe845114
commit
f057a7f296
1 changed files with 39 additions and 0 deletions
|
|
@ -23,6 +23,7 @@ import {
|
|||
import { useAuth } from "@/contexts/AuthContext";
|
||||
import FourOhFourPage from "@/pages/404";
|
||||
import { Clock, Rocket, Target, ExternalLink, Award } from "lucide-react";
|
||||
import { aethexSocialService } from "@/lib/aethex-social-service";
|
||||
|
||||
interface ProjectPreview {
|
||||
id: string;
|
||||
|
|
@ -57,6 +58,8 @@ const ProfilePassport = () => {
|
|||
(AethexUserProfile & { email?: string | null }) | null
|
||||
>(null);
|
||||
const [achievements, setAchievements] = useState<AethexAchievement[]>([]);
|
||||
const [followStats, setFollowStats] = useState<{ followers: number; following: number }>({ followers: 0, following: 0 });
|
||||
const [degree, setDegree] = useState<string>("");
|
||||
const [projects, setProjects] = useState<ProjectPreview[]>([]);
|
||||
const [interests, setInterests] = useState<string[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
|
@ -258,6 +261,33 @@ const ProfilePassport = () => {
|
|||
);
|
||||
setNotFound(false);
|
||||
|
||||
try {
|
||||
const [followingIds, followerIds] = await Promise.all([
|
||||
aethexSocialService.getFollowing(resolvedId),
|
||||
aethexSocialService.getFollowers(resolvedId),
|
||||
]);
|
||||
if (!cancelled) setFollowStats({ following: followingIds.length, followers: followerIds.length });
|
||||
} catch {}
|
||||
try {
|
||||
const me = user?.id || null;
|
||||
if (me && resolvedId && me !== resolvedId) {
|
||||
const myConns = await aethexSocialService.getConnections(me);
|
||||
const first = new Set(myConns.map((c: any) => c.connection_id));
|
||||
if (first.has(resolvedId)) setDegree("1st");
|
||||
else {
|
||||
const secondLists = await Promise.all(
|
||||
Array.from(first).slice(0, 50).map((id) => aethexSocialService.getConnections(id)),
|
||||
);
|
||||
const second = new Set(secondLists.flat().map((c: any) => c.connection_id));
|
||||
setDegree(second.has(resolvedId) ? "2nd" : "3rd+");
|
||||
}
|
||||
} else if (me && resolvedId && me === resolvedId) {
|
||||
setDegree("1st");
|
||||
} else {
|
||||
setDegree("");
|
||||
}
|
||||
} catch {}
|
||||
|
||||
lastLoadedKeyRef.current =
|
||||
targetKey ??
|
||||
(resolvedProfile.username
|
||||
|
|
@ -517,6 +547,15 @@ const ProfilePassport = () => {
|
|||
)}
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-2 text-sm text-slate-300">
|
||||
<Badge variant="outline" className="border-slate-700/70 bg-slate-900/40">
|
||||
Followers: {followStats.followers}
|
||||
</Badge>
|
||||
<Badge variant="outline" className="border-slate-700/70 bg-slate-900/40">
|
||||
Following: {followStats.following}
|
||||
</Badge>
|
||||
{degree && (
|
||||
<Badge className="bg-aethex-500/20 text-aethex-100">{degree} degree</Badge>
|
||||
)}
|
||||
{profile.github_url && (
|
||||
<Button
|
||||
asChild
|
||||
|
|
|
|||
Loading…
Reference in a new issue