user-info.tsx 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { useTranslation } from 'react-i18next'
  2. import { useRouter } from 'next/navigation'
  3. import Button from '@/app/components/base/button'
  4. import { useAppContext } from '@/context/app-context'
  5. import { logout } from '@/service/common'
  6. import Avatar from '@/app/components/base/avatar'
  7. import { Triangle } from '@/app/components/base/icons/src/public/education'
  8. const UserInfo = () => {
  9. const router = useRouter()
  10. const { t } = useTranslation()
  11. const { userProfile } = useAppContext()
  12. const handleLogout = async () => {
  13. await logout({
  14. url: '/logout',
  15. params: {},
  16. })
  17. localStorage.removeItem('setup_status')
  18. localStorage.removeItem('console_token')
  19. localStorage.removeItem('refresh_token')
  20. router.push('/signin')
  21. }
  22. return (
  23. <div className='relative flex items-center justify-between rounded-xl border-[4px] border-components-panel-on-panel-item-bg bg-gradient-to-r from-background-gradient-bg-fill-chat-bg-2 to-background-gradient-bg-fill-chat-bg-1 pb-6 pl-6 pr-8 pt-9 shadow-shadow-shadow-5'>
  24. <div className='absolute left-0 top-0 flex items-center'>
  25. <div className='system-2xs-semibold-uppercase flex h-[22px] items-center bg-components-panel-on-panel-item-bg pl-2 pt-1 text-text-accent-light-mode-only'>
  26. {t('education.currentSigned')}
  27. </div>
  28. <Triangle className='h-[22px] w-4 text-components-panel-on-panel-item-bg' />
  29. </div>
  30. <div className='flex items-center'>
  31. <Avatar
  32. className='mr-4'
  33. avatar={userProfile.avatar_url}
  34. name={userProfile.name}
  35. size={48}
  36. />
  37. <div className='pt-1.5'>
  38. <div className='system-md-semibold text-text-primary'>
  39. {userProfile.name}
  40. </div>
  41. <div className='system-sm-regular text-text-secondary'>
  42. {userProfile.email}
  43. </div>
  44. </div>
  45. </div>
  46. <Button
  47. variant='secondary'
  48. onClick={handleLogout}
  49. >
  50. {t('common.userProfile.logout')}
  51. </Button>
  52. </div>
  53. )
  54. }
  55. export default UserInfo