import { useMessageThread } from "@replyke/react-js";
function ThreadPanel({
conversationId,
messageId,
}: {
conversationId: string;
messageId: string;
}) {
const { replies, loading, hasMore, loadMore, sendReply } = useMessageThread({
conversationId,
messageId,
});
const [text, setText] = useState("");
const handleReply = async () => {
if (!text.trim()) return;
await sendReply({ content: text });
setText("");
};
return (
<div>
<h3>Thread</h3>
{replies.map((reply) => (
<div key={reply.id}>
<strong>{reply.user?.name}</strong>: {reply.content}
</div>
))}
{hasMore && <button onClick={loadMore}>Load more</button>}
<input
value={text}
onChange={(e) => setText(e.target.value)}
placeholder="Reply..."
/>
<button onClick={handleReply}>Reply</button>
</div>
);
}