|
|
@@ -5,17 +5,14 @@ import { AiAssistantShareScope, type AiAssistantHasId } from '../../../../interf
|
|
|
|
|
|
type ThreadItemProps = {
|
|
|
name: string;
|
|
|
- onClick?: () => void;
|
|
|
};
|
|
|
|
|
|
const ThreadItem: React.FC<ThreadItemProps> = ({
|
|
|
name,
|
|
|
- onClick,
|
|
|
}) => {
|
|
|
return (
|
|
|
<li
|
|
|
className="list-group-item list-group-item-action border-0 d-flex align-items-center rounded-1 ps-5"
|
|
|
- onClick={onClick}
|
|
|
role="button"
|
|
|
>
|
|
|
<div>
|
|
|
@@ -46,7 +43,6 @@ type AiAssistantItemProps = {
|
|
|
shareScope: AiAssistantShareScope;
|
|
|
accessScope: AiAssistantAccessScope;
|
|
|
threads: { id: string; name: string }[]; // dummy data
|
|
|
- onThreadClick?: (threadId: string) => void;
|
|
|
};
|
|
|
|
|
|
const AiAssistantItem: React.FC<AiAssistantItemProps> = ({
|
|
|
@@ -54,31 +50,24 @@ const AiAssistantItem: React.FC<AiAssistantItemProps> = ({
|
|
|
shareScope,
|
|
|
accessScope,
|
|
|
threads,
|
|
|
- onThreadClick,
|
|
|
}) => {
|
|
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
|
|
|
|
- const handleToggle = useCallback(() => {
|
|
|
- setIsExpanded(prev => !prev);
|
|
|
+ const clickItemHandler = useCallback(() => {
|
|
|
+ setIsExpanded(toggle => !toggle);
|
|
|
}, []);
|
|
|
|
|
|
- const handleButtonClick = useCallback((e: React.MouseEvent) => {
|
|
|
- e.stopPropagation();
|
|
|
- handleToggle();
|
|
|
- }, [handleToggle]);
|
|
|
-
|
|
|
return (
|
|
|
<div className="grw-ai-assistant-item-container">
|
|
|
<li
|
|
|
className="list-group-item list-group-item-action border-0 d-flex align-items-center rounded-1"
|
|
|
- onClick={handleToggle}
|
|
|
+ onClick={clickItemHandler}
|
|
|
role="button"
|
|
|
>
|
|
|
<div className="grw-triangle-container d-flex justify-content-center">
|
|
|
<button
|
|
|
type="button"
|
|
|
className={`grw-ai-assistant-triangle-btn btn px-0 ${isExpanded ? 'grw-ai-assistant-open' : ''}`}
|
|
|
- onClick={handleButtonClick}
|
|
|
>
|
|
|
<div className="d-flex justify-content-center">
|
|
|
<span className="material-symbols-outlined fs-5">arrow_right</span>
|
|
|
@@ -99,7 +88,6 @@ const AiAssistantItem: React.FC<AiAssistantItemProps> = ({
|
|
|
<ThreadItem
|
|
|
key={thread.id}
|
|
|
name={thread.name}
|
|
|
- onClick={() => onThreadClick?.(thread.id)}
|
|
|
/>
|
|
|
))}
|
|
|
</div>
|
|
|
@@ -130,7 +118,6 @@ export const AiAssistantTree: React.FC<AiAssistantTreeProps> = ({ aiAssistants,
|
|
|
shareScope={assistant.shareScope}
|
|
|
accessScope={assistant.accessScope}
|
|
|
threads={dummyThreads}
|
|
|
- onThreadClick={onThreadClick}
|
|
|
/>
|
|
|
))}
|
|
|
</ul>
|