"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 action row.
*
* The action row hosts:
* • "Edit profile" link — only on the owner's own profile (via the
* `editHref` prop set by /u/me layout).
* • Reading-settings gear — also owner-only. We use `editHref` as the
* "is this my profile?" signal (the /u/me layout passes it; the
* /u/[handle] layout does not), so the two buttons stay in lockstep
* and visitors on someone else's profile see a clean row with no
* personal-settings affordances. The gear links to /settings (the
* dedicated settings page) rather than opening a popover —
* centred-row popovers tend to spill off the left edge on narrow
* viewports.
*
* Auth users on someone else's profile reach reading settings via the
* sidebar rail on desktop. Anonymous visitors use SiteHeader's mobile
* gear.
*/
import Image from "next/image";
import Link from "next/link";
import { Settings } from "lucide-react";
import { cn } from "@/lib/utils";
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 AND
* the reading-settings gear. Acts as the canonical "this is my own
* profile" signal across the action row. */
editHref?: string;
}) {
// Both action-row affordances are owner-only and ride on the same
// `editHref` signal — when it's absent we render no action row at
// all, which keeps visitor profile views clean.
const showReadingSettings = !!editHref;
const showActions = !!editHref;
return (
@{handle}
{typeof postCount === "number" ? (
<>
{postCount} post
{postCount === 1 ? "" : "s"}
>
) : null}
{typeof postCount === "number" && joinedAt ? " · " : null}
{joinedAt ? <>Joined {new Date(joinedAt).toLocaleDateString()}> : null}
{name}