UserHeader.tsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { Copy } from 'lucide-react'
  2. import { cn } from 'ui'
  3. import { PANEL_PADDING } from './Users.constants'
  4. import { getDisplayName } from './Users.utils'
  5. import CopyButton from '@/components/ui/CopyButton'
  6. import { User } from '@/data/auth/users-infinite-query'
  7. export const UserHeader = ({ user }: { user: User }) => {
  8. const displayName = getDisplayName(user)
  9. const hasDisplayName = displayName !== '-'
  10. const isPhoneAuth = user.phone !== null
  11. const isAnonUser = user.is_anonymous
  12. return (
  13. <div className={cn(PANEL_PADDING)}>
  14. {isPhoneAuth ? (
  15. <div className="flex items-center gap-x-1">
  16. <p>{user.phone}</p>
  17. <CopyButton
  18. iconOnly
  19. type="text"
  20. icon={<Copy />}
  21. className="px-1"
  22. text={user?.phone ?? ''}
  23. />
  24. </div>
  25. ) : isAnonUser ? (
  26. <>
  27. <p>Anonymous user</p>
  28. <div className="flex items-center gap-x-1">
  29. <p className="text-foreground-light text-sm">{user.id}</p>
  30. <CopyButton
  31. iconOnly
  32. type="text"
  33. icon={<Copy />}
  34. className="px-1"
  35. text={user?.id ?? ''}
  36. />
  37. </div>
  38. </>
  39. ) : (
  40. <>
  41. {hasDisplayName && <p>{displayName}</p>}
  42. <div className="flex items-center gap-x-1">
  43. <p className={cn(hasDisplayName ? 'text-foreground-light text-sm' : 'text-foreground')}>
  44. {user.email}
  45. </p>
  46. <CopyButton
  47. iconOnly
  48. type="text"
  49. icon={<Copy />}
  50. className="px-1"
  51. text={user?.email ?? ''}
  52. />
  53. </div>
  54. </>
  55. )}
  56. </div>
  57. )
  58. }