'use client' import { useEffect, useState } from 'react' export default function ProfileDropdown() { const [open, setOpen] = useState(false) const [profile, setProfile] = useState<{ user?: string; email?: string }>({}) useEffect(() => { fetch('/api/me') .then((res) => res.json()) .then((data) => setProfile(data)) .catch(() => setProfile({})) }, []) const handleLogout = async () => { window.location.href = '/logout' } const name = profile.email || profile.user || 'Loading...' return (
{open && (
{name}
)}
) }