'use client' import { useTranslation } from 'react-i18next' import { Fragment, useState } from 'react' import { useRouter } from 'next/navigation' import { useContext } from 'use-context-selector' import { RiArrowDownSLine } from '@remixicon/react' import Link from 'next/link' import { Menu, Transition } from '@headlessui/react' import Indicator from '../indicator' import AccountAbout from '../account-about' import { mailToSupport } from '../utils/util' import WorkplaceSelector from './workplace-selector' import classNames from '@/utils/classnames' import I18n from '@/context/i18n' import Avatar from '@/app/components/base/avatar' import { logout } from '@/service/common' import { useAppContext } from '@/context/app-context' import { ArrowUpRight } from '@/app/components/base/icons/src/vender/line/arrows' import { LogOut01 } from '@/app/components/base/icons/src/vender/line/general' import { useModalContext } from '@/context/modal-context' import { LanguagesSupported } from '@/i18n/language' import { useProviderContext } from '@/context/provider-context' import { Plan } from '@/app/components/billing/type' export type IAppSelector = { isMobile: boolean } export default function AppSelector({ isMobile }: IAppSelector) { const itemClassName = ` flex items-center w-full h-9 px-3 text-gray-700 text-[14px] rounded-lg font-normal hover:bg-gray-50 cursor-pointer ` const router = useRouter() const [aboutVisible, setAboutVisible] = useState(false) const { locale } = useContext(I18n) const { t } = useTranslation() const { userProfile, langeniusVersionInfo } = useAppContext() const { setShowAccountSettingModal } = useModalContext() const { plan } = useProviderContext() const canEmailSupport = plan.type === Plan.professional || plan.type === Plan.team || plan.type === Plan.enterprise const handleLogout = async () => { await logout({ url: '/logout', params: {}, }) localStorage.removeItem('setup_status') localStorage.removeItem('console_token') localStorage.removeItem('refresh_token') router.push('/signin') } return (
{ ({ open }) => ( <>
{!isMobile && <> {userProfile.name} }
{userProfile.name}
{userProfile.email}
{t('common.userProfile.workspace')}
{t('common.account.account')}
setShowAccountSettingModal({ payload: 'members' })}>
{t('common.userProfile.settings')}
{canEmailSupport &&
{t('common.userProfile.emailSupport')}
}
{t('common.userProfile.communityFeedback')}
{t('common.userProfile.community')}
{t('common.userProfile.helpCenter')}
{t('common.userProfile.roadmap')}
{ document?.body?.getAttribute('data-public-site-about') !== 'hide' && (
setAboutVisible(true)}>
{t('common.userProfile.about')}
{langeniusVersionInfo.current_version}
) }
handleLogout()}>
{t('common.userProfile.logout')}
) }
{ aboutVisible && setAboutVisible(false)} langeniusVersionInfo={langeniusVersionInfo} /> }
) }