forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSuggestion.tsx
More file actions
35 lines (32 loc) · 774 Bytes
/
Copy pathSuggestion.tsx
File metadata and controls
35 lines (32 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { useCopilotChatInternal } from "@copilotkit/react-core";
import { SmallSpinnerIcon } from "./Icons";
interface SuggestionsProps {
title: string;
message: string;
partial?: boolean;
className?: string;
onClick: () => void;
}
export function Suggestion({
title,
onClick,
partial,
className,
}: SuggestionsProps) {
const { isLoading } = useCopilotChatInternal();
if (!title) return null;
return (
<button
disabled={partial || isLoading}
onClick={(e) => {
e.preventDefault();
onClick();
}}
className={`suggestion ${className ?? ""} ${partial ? "loading" : ""}`}
data-test-id="suggestion"
type="button"
>
{partial ? SmallSpinnerIcon : <span>{title}</span>}
</button>
);
}