tahamajs/IE / Projects /front /src /components /profile /ProfileHeader.tsx
tahamajs's picture
download
raw
2.02 kB
import { Link } from "react-router-dom";
import { User } from "@/types";
interface ProfileHeaderProps {
profile: User;
isFollowing: boolean;
followLoading: boolean;
onFollowToggle: () => void;
currentUsername?: string;
}
export function ProfileHeader({
profile,
isFollowing,
followLoading,
onFollowToggle,
currentUsername,
}: ProfileHeaderProps) {
const displayName = profile.fullName || profile.username;
const avatarUrl = profile.avatarUrl || "/default-avatar.png";
const followers = profile.followersCount ?? 0;
const following = profile.followingCount ?? 0;
const articles = profile.articlesCount ?? 0;
return (
<div className="bg-white dark:bg-gray-800 rounded-2xl shadow p-8 flex flex-col md:flex-row gap-6 items-start">
<img
src={avatarUrl}
className="w-24 h-24 rounded-full object-cover border-2 border-primary/20"
alt={displayName}
/>
<div className="flex-1">
<h1 className="text-3xl font-bold">{displayName}</h1>
<p className="text-gray-500 dark:text-gray-400">@{profile.username}</p>
{profile.bio && <p className="mt-2 text-gray-700 dark:text-gray-300">{profile.bio}</p>}
<div className="flex flex-wrap gap-4 mt-2 text-sm">
<span>
<strong>{followers.toLocaleString()}</strong> followers
</span>
<span>
<strong>{following.toLocaleString()}</strong> following
</span>
<span>
<strong>{articles.toLocaleString()}</strong> articles
</span>
</div>
{currentUsername && currentUsername !== profile.username && (
<button
onClick={onFollowToggle}
disabled={followLoading}
className={`btn mt-3 ${followLoading ? "opacity-60 cursor-wait" : isFollowing ? "btn-secondary" : "btn-primary"}`}
>
{followLoading ? "Please wait…" : isFollowing ? "Unfollow" : "Follow"}
</button>
)}
</div>
</div>
);
}

Xet Storage Details

Size:
2.02 kB
·
Xet hash:
9fa8025a33bf65c8192c8523c1fb4788f1ec270e6ede074fa98c2cc775a60543

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