2024-09-18 10:03:36 +02:00
|
|
|
import React, { ForwardedRef } from 'react';
|
|
|
|
|
|
|
|
interface ConversationProps {
|
|
|
|
messages: string[];
|
2024-09-18 11:17:34 +02:00
|
|
|
onResendClick: () => void;
|
|
|
|
onEditClick: () => void;
|
|
|
|
onCopyClick: () => void;
|
2024-09-18 10:03:36 +02:00
|
|
|
}
|
|
|
|
|
2024-09-18 11:17:34 +02:00
|
|
|
const Conversation = React.forwardRef<HTMLDivElement, ConversationProps>(
|
|
|
|
({ messages, onResendClick, onEditClick, onCopyClick }, ref: ForwardedRef<HTMLDivElement>) => {
|
|
|
|
return (
|
|
|
|
<div className="output">
|
|
|
|
<div className="conversation resize" id="conversation" ref={ref}>
|
|
|
|
{messages.map((message, index) => {
|
|
|
|
const isUserMessage = message.startsWith('User:');
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
key={index}
|
|
|
|
className={isUserMessage ? 'user-message' : 'ai-message'}
|
|
|
|
>
|
|
|
|
{message}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
<div className="button-container">
|
|
|
|
<button type="button" onClick={onResendClick}>
|
|
|
|
<img src="/img/resend.svg" alt="resend" />
|
|
|
|
</button>
|
|
|
|
<button type="button" onClick={onEditClick}>
|
|
|
|
<img src="/img/edit.svg" alt="edit" />
|
|
|
|
</button>
|
|
|
|
<button type="button" onClick={onCopyClick}>
|
|
|
|
<img src="/img/copy.svg" alt="copy" />
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-09-18 10:03:36 +02:00
|
|
|
</div>
|
2024-09-18 11:17:34 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
2024-09-18 10:03:36 +02:00
|
|
|
|
|
|
|
export default Conversation;
|