Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

2.1 KB
Raw Blame
import { Avatar, AvatarFallback, AvatarImage } from '@langgenius/dify-ui/avatar'
import { Button } from '@langgenius/dify-ui/button'
import { useSuspenseQuery } from '@tanstack/react-query'
import { useTranslation } from 'react-i18next'
import { userProfileQueryOptions } from '@/features/account-profile/client'
import { useLogout } from '@/service/use-common'
import { getAvatarInitial } from '@/utils/avatar'

const UserInfo = () => {
  const { t } = useTranslation(['common', 'education'])
  const { data: userProfile } = useSuspenseQuery({
    ...userProfileQueryOptions(),
    select: (data) => data.profile,
  })

  const { mutate: logout } = useLogout()

  return (
    <div className="relative flex items-center justify-between rounded-xl border-4 border-components-panel-on-panel-item-bg bg-linear-to-r from-background-gradient-bg-fill-chat-bg-2 to-background-gradient-bg-fill-chat-bg-1 pt-9 pr-8 pb-6 pl-6 shadow-shadow-shadow-5">
      <div className="absolute top-0 left-0 flex items-center">
        <div className="flex h-5.5 items-center bg-components-panel-on-panel-item-bg pt-1 pl-2 system-2xs-semibold-uppercase text-text-accent-light-mode-only">
          {t(($) => $.currentSigned, { ns: 'education' })}
        </div>
        <span
          className="i-custom-public-education-triangle h-5.5 w-4 text-components-panel-on-panel-item-bg"
          aria-hidden="true"
        />
      </div>
      <div className="flex items-center">
        <Avatar className="mr-4" size="2xl" aria-hidden="true">
          <AvatarFallback>{getAvatarInitial(userProfile.name)}</AvatarFallback>
          <AvatarImage src={userProfile.avatar_url || undefined} alt="" />
        </Avatar>
        <div className="pt-1.5">
          <div className="system-md-semibold text-text-primary">{userProfile.name}</div>
          <div className="system-sm-regular text-text-secondary">{userProfile.email}</div>
        </div>
      </div>
      <Button variant="secondary" onClick={() => logout()}>
        {t(($) => $['userProfile.logout'], { ns: 'common' })}
      </Button>
    </div>
  )
}

export default UserInfo