{messages.length === 0 ? (
Nenhuma mensagem ainda
O agente iniciara a conversa em breve
) : (
{messages.map((msg) => {
const isAgent = !msg.isFromMachine
const bodyText = msg.body.trim()
const shouldShowBody =
bodyText.length > 0 && !(bodyText === "[Anexo]" && (msg.attachments?.length ?? 0) > 0)
return (
{firstUnreadAgentMessageId === msg.id && unreadCount > 0 && !isAtBottom && (
)}
{
if (el) {
messageElementsRef.current.set(msg.id, el)
} else {
messageElementsRef.current.delete(msg.id)
}
}}
className={`flex gap-2 ${isAgent ? "flex-row-reverse" : "flex-row"}`}
>
{/* Avatar */}
{isAgent ? : }
{/* Bubble */}
{!isAgent && (
{msg.authorName}
)}
{shouldShowBody &&
{msg.body}
}
{/* Anexos */}
{msg.attachments && msg.attachments.length > 0 && (
{msg.attachments.map((att) => (
))}
)}
{formatTime(msg.createdAt)}
)
})}
)}
{unreadCount > 0 && !isAtBottom && (
)}
{/* Anexos pendentes */}
{pendingAttachments.length > 0 && (
{pendingAttachments.map((att) => (
{getFileIcon(att.name)}
{att.name}
))}
)}