"use client"; /** * ProfileHeader — Instagram-style centered header used at the top of * /u/me and /u/[handle]. Avatar, display name, @handle, a single stat * line, and an optional action slot (Edit profile button on owner view). * * Replaces the older ProfileViewHeader (left-aligned avatar + sidebar). */ import Image from "next/image"; import Link from "next/link"; export function ProfileHeader({ avatarURL, name, handle, postCount, joinedAt, editHref, }: { avatarURL: string | null; name: string; handle: string; postCount?: number; joinedAt?: string; /** When provided, shows an "Edit profile" CTA below the handle. */ editHref?: string; }) { return (

{name}

@{handle}

{typeof postCount === "number" || joinedAt ? (

{typeof postCount === "number" ? ( <> {postCount} post {postCount === 1 ? "" : "s"} ) : null} {typeof postCount === "number" && joinedAt ? " · " : null} {joinedAt ? <>Joined {new Date(joinedAt).toLocaleDateString()} : null}

) : null}
{editHref ? ( Edit profile ) : null}
); } function Avatar({ src, name }: { src: string | null; name: string }) { if (src) { return ( {name} ); } const initials = name .split(/\s+/) .map((p) => p[0]) .slice(0, 2) .join("") .toUpperCase() || "?"; return (
{initials}
); }