import { Bot, User, Copy, File } from "lucide-react"; import ReactMarkdown from "react-markdown"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { useState } from "react"; import { useToast } from "@/hooks/use-toast"; interface ChatMessageProps { role: "user" | "assistant"; content: string; model?: string; attachments?: Array<{ name: string; type: string; size: number; }>; } export const ChatMessage = ({ role, content, model, attachments }: ChatMessageProps) => { const [showActions, setShowActions] = useState(false); const { toast } = useToast(); const isAssistant = role === "assistant"; const handleCopy = () => { navigator.clipboard.writeText(content); toast({ title: "Copiado!", description: "Mensagem copiada para a área de transferência", }); }; return (
setShowActions(true)} onMouseLeave={() => setShowActions(false)} > {isAssistant && (
{model && ( {model} )}
)}
{/* Attachments */} {attachments && attachments.length > 0 && (
{attachments.map((file, index) => (
{file.name} ({(file.size / 1024).toFixed(1)} KB)
))}
)}
{isAssistant ? (
{content}
) : (

{content}

)}
{showActions && (
)}
{!isAssistant && (
)}
); };