"use client"; import { useEffect, useState } from "react"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { useTranslation } from "react-i18next"; import { fetchAuthStatus, type AuthStatus } from "@/lib/auth"; import { UserAvatar } from "@/components/UserAvatar"; interface ProfileLinkProps { collapsed?: boolean; } export function ProfileLink({ collapsed = false }: ProfileLinkProps) { const pathname = usePathname(); const { t } = useTranslation(); const [status, setStatus] = useState(null); useEffect(() => { fetchAuthStatus().then((next) => { // Only surface the link when auth is on AND the user is signed in. if (next?.enabled && next?.authenticated) setStatus(next); }); }, []); if (!status?.username) return null; const active = pathname.startsWith("/profile"); const avatar = ( ); if (collapsed) { return ( {avatar} ); } return ( {avatar} {status.username} ); }