"use client"; import { authClient } from "@/lib/auth-client"; import { useRouter } from "@/i18n/routing"; import { Link } from "@/i18n/routing"; import { useState } from "react"; import { useTranslations } from "next-intl"; export default function DashboardProfile() { const t = useTranslations('Profile'); const { data: session, isPending } = authClient.useSession(); const router = useRouter(); const [isOpen, setIsOpen] = useState(false); // If loading, show skeleton if (isPending) { return (
) } // If no session, show nothing (or could show login button, but dashboard is protected) if (!session) { return null; } const user = session.user; const initials = user.name ? user.name .split(" ") .map((n) => n[0]) .join("") .toUpperCase() .slice(0, 2) : "??"; // Attempt to get role from user object if it exists (custom field), or default // @ts-ignore - role might not be in the default type definition yet const role = user.role || "Member"; const handleSignOut = async () => { await authClient.signOut(); router.push("/auth/signin"); }; return (
{/* Dropdown Menu */} {isOpen && ( <>
setIsOpen(false)} >

{user.name}

{user.email}

setIsOpen(false)} > {t('profileSettings')}
)}
); }