interstellar_ai/app/ConversationFrontend.tsx

46 lines
1.4 KiB
TypeScript
Raw Normal View History

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 14:52:04 +02:00
const ConversationFrontend = React.forwardRef<HTMLDivElement, ConversationProps>(
2024-09-18 11:17:34 +02:00
({ 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'}
>
2024-09-18 15:03:32 +02:00
<p>
2024-09-18 11:17:34 +02:00
{message}
2024-09-18 15:03:32 +02:00
</p>
2024-09-18 11:17:34 +02:00
</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
2024-09-18 14:52:04 +02:00
export default ConversationFrontend;