import { Command, FlaskConical, Loader2, Settings } from 'lucide-react' import { useTheme } from 'next-themes' import Link from 'next/link' import { useRouter } from 'next/router' import { ProfileImage } from 'components/ui/ProfileImage' import { useProfileIdentitiesQuery } from 'data/profile/profile-identities-query' import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled' import { useSignOut } from 'lib/auth' import { IS_PLATFORM } from 'lib/constants' import { getGitHubProfileImgUrl } from 'lib/github' import { useProfile } from 'lib/profile' import { useAppStateSnapshot } from 'state/app-state' import { Button, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuTrigger, Theme, singleThemes, } from 'ui' import { useSetCommandMenuOpen } from 'ui-patterns/CommandMenu' import { useFeaturePreviewModal } from './App/FeaturePreview/FeaturePreviewContext' export function UserDropdown() { const router = useRouter() const signOut = useSignOut() const { profile, isLoading: isLoadingProfile } = useProfile() const { theme, setTheme } = useTheme() const appStateSnapshot = useAppStateSnapshot() const setCommandMenuOpen = useSetCommandMenuOpen() const { openFeaturePreviewModal } = useFeaturePreviewModal() const profileShowEmailEnabled = useIsFeatureEnabled('profile:show_email') const { username, primary_email } = profile ?? {} const { data, isLoading: isLoadingIdentities } = useProfileIdentitiesQuery() const isGitHubProfile = profile?.auth0_id.startsWith('github') const gitHubUsername = isGitHubProfile ? (data?.identities ?? []).find((x) => x.provider === 'github')?.identity_data?.user_name : undefined const profileImageUrl = isGitHubProfile ? getGitHubProfileImgUrl(gitHubUsername) : undefined return ( {IS_PLATFORM && ( <>
{profile && ( <> {username} {primary_email !== username && profileShowEmailEnabled && ( {primary_email} )} )}
{ if (router.pathname !== '/account/me') { appStateSnapshot.setLastRouteBeforeVisitingAccountPage(router.asPath) } }} > Account preferences Feature previews setCommandMenuOpen(true)}> Command menu )} Theme { setTheme(value) }} > {singleThemes.map((theme: Theme) => ( {theme.name} ))} {IS_PLATFORM && ( <> { await signOut() }} > Log out )}
) }