import { forwardRef, useState } from 'react'; import Avatar from '../Avatar'; import { FEEDBACK, MESSAGE_TYPE } from './conversationModels'; import Alert from './../assets/alert.svg'; import { ReactComponent as Like } from './../assets/like.svg'; import { ReactComponent as Dislike } from './../assets/dislike.svg'; const ConversationBubble = forwardRef< HTMLDivElement, { message: string; type: MESSAGE_TYPE; className?: string; feedback?: FEEDBACK; handleFeedback?: (feedback: FEEDBACK) => void; } >(function ConversationBubble( { message, type, className, feedback, handleFeedback }, ref, ) { const [showFeedback, setShowFeedback] = useState(false); // const [overriddenFeedback, setOverriddenFeedback] = useState< // FEEDBACK | undefined // >(undefined); // const effectiveFeedback = overriddenFeedback ?? feedback; let bubble; if (type === 'QUESTION') { bubble = (

{message}

); } else { bubble = (
setShowFeedback(true)} onMouseLeave={() => setShowFeedback(false)} >
{type === 'ERROR' && ( alert )}

{message}

handleFeedback?.('LIKE')} >
handleFeedback?.('DISLIKE')} >
); } return bubble; }); export default ConversationBubble;