| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- import { Copy } from 'lucide-react'
- import { cn } from 'ui'
- import { PANEL_PADDING } from './Users.constants'
- import { getDisplayName } from './Users.utils'
- import CopyButton from '@/components/ui/CopyButton'
- import { User } from '@/data/auth/users-infinite-query'
- export const UserHeader = ({ user }: { user: User }) => {
- const displayName = getDisplayName(user)
- const hasDisplayName = displayName !== '-'
- const isPhoneAuth = user.phone !== null
- const isAnonUser = user.is_anonymous
- return (
- <div className={cn(PANEL_PADDING)}>
- {isPhoneAuth ? (
- <div className="flex items-center gap-x-1">
- <p>{user.phone}</p>
- <CopyButton
- iconOnly
- type="text"
- icon={<Copy />}
- className="px-1"
- text={user?.phone ?? ''}
- />
- </div>
- ) : isAnonUser ? (
- <>
- <p>Anonymous user</p>
- <div className="flex items-center gap-x-1">
- <p className="text-foreground-light text-sm">{user.id}</p>
- <CopyButton
- iconOnly
- type="text"
- icon={<Copy />}
- className="px-1"
- text={user?.id ?? ''}
- />
- </div>
- </>
- ) : (
- <>
- {hasDisplayName && <p>{displayName}</p>}
- <div className="flex items-center gap-x-1">
- <p className={cn(hasDisplayName ? 'text-foreground-light text-sm' : 'text-foreground')}>
- {user.email}
- </p>
- <CopyButton
- iconOnly
- type="text"
- icon={<Copy />}
- className="px-1"
- text={user?.email ?? ''}
- />
- </div>
- </>
- )}
- </div>
- )
- }
|