import * as DropdownMenu from '@radix-ui/react-dropdown-menu'; import classNames from 'classnames'; import { motion } from 'framer-motion'; import { useMemo } from 'react'; import { useAuth } from '~/lib/hooks/useAuth'; import type { TabType } from './types'; interface AvatarDropdownProps { onSelectTab: (tab: TabType) => void; } export const AvatarDropdown = ({ onSelectTab }: AvatarDropdownProps) => { const { userInfo, isAuthenticated } = useAuth(); const displayName = useMemo(() => { if (!isAuthenticated || !userInfo) { return 'Guest User'; } return userInfo.name || userInfo.username; }, [userInfo]); const contactInfo = useMemo(() => { if (!isAuthenticated || !userInfo) { return null; } if (userInfo.phone_number) { return `+${userInfo.phone_number}`; } return userInfo.email; }, [userInfo]); const avatarUrl = isAuthenticated && userInfo?.picture ? userInfo.picture : ''; return ( {avatarUrl ? ( {displayName} ) : (
)}
{avatarUrl ? ( {displayName} ) : (
?
)}
{displayName}
{isAuthenticated && userInfo?.email && (
{contactInfo}
)}
onSelectTab('settings')} >
Settings
onSelectTab('task-manager')} >
Task Manager ); };