import { useConfig } from 'domains/config/hooks'
import { useI18n } from 'domains/i18n/hooks'
import { className } from 'lib/css'
import { VNode } from 'preact'
import { useSeamlyParticipant } from 'ui/hooks/seamly-hooks'
const EventParticipant = ({ eventPayload }) => {
const { t } = useI18n()
const { fromClient, participant: participantId } = eventPayload
const participant = useSeamlyParticipant(participantId) || {}
const { messages } = useConfig()
const participantName = fromClient
? t('participants.user.name')
: participant && participant.name
const { showAvatar, showName } =
(messages && messages[fromClient ? 'user' : 'agent']) || {}
if (!showAvatar && !showName) {
return null
}
const authorInfo: VNode[] = []
if (showAvatar && participantName && participant.avatar) {
authorInfo.push(
,
)
}
if (showName && participantName) {
authorInfo.push(
{participantName}
,
)
}
return authorInfo.length > 0 ? (