'use client'; import { Skeleton, Avatar, Group, Alert, Menu, Card, Text, UnstyledButton, Stack, } from '@mantine/core'; import { useMantineColorScheme } from '@mantine/core'; import useMyProfile from '../../lib/queries/useMyProfile'; import { MdOutlineBugReport, MdOutlineCollectionsBookmark, MdOutlineSmartphone, MdOutlineDarkMode, MdOutlineLightMode, } from 'react-icons/md'; import { TbStackForward } from 'react-icons/tb'; import { useAuth } from '@/hooks/useAuth'; import { useRouter } from 'next/navigation'; import Link from 'next/link'; import { IoMdLogOut } from 'react-icons/io'; import { useNavbarContext } from '@/providers/navbar'; import { useOs } from '@mantine/hooks'; import { BsThreeDots } from 'react-icons/bs'; import styles from './ProfileMenu.module.css'; import { sanitizeText } from '@/lib/utils/text'; import { isBotAccount } from '@/features/platforms/bluesky/lib/utils/account'; import BotLabel from '../botLabel/BotLabel'; const schemes = ['light', 'dark', 'auto'] as const; type ColorScheme = (typeof schemes)[number]; const schemeConfig: Record< ColorScheme, { icon: React.ReactNode; label: string; next: ColorScheme } > = { light: { icon: , label: 'Light', next: 'dark', }, dark: { icon: , label: 'Dark', next: 'auto' }, auto: { icon: , label: 'Auto', next: 'light', }, }; export default function ProfileMenu() { const router = useRouter(); const os = useOs(); const { toggleMobile } = useNavbarContext(); const { data, error, isPending } = useMyProfile(); const { logout } = useAuth(); const { colorScheme, setColorScheme } = useMantineColorScheme(); const current = schemeConfig[colorScheme as ColorScheme] ?? schemeConfig.auto; const handleLogout = async () => { try { await logout(); router.push('/'); } catch (error) { console.error('Error logging out:', error); } }; if (isPending || !data) { return ; } if (error) { return ; } return ( {data.name} {isBotAccount(data) && } {sanitizeText(data.name) || data.handle} {isBotAccount(data) && } @{data.handle} setColorScheme(current.next)} > Theme: {current.label} } color="gray" > Submit an issue } component={Link} href={'/bookmarklet'} target="_blank" > Install bookmarklet {os === 'ios' && ( } component={Link} href={ 'https://www.icloud.com/shortcuts/9c4b4b4bc4ef4d6d93513c59373b0af6' } target="_blank" > Install iOS shortcut )} } onClick={handleLogout} > Log out ); }