|
@@ -8,6 +8,7 @@ import { useCurrentUser } from '~/stores-universal/context';
|
|
|
import type { AiAssistantAccessScope } from '../../../../interfaces/ai-assistant';
|
|
import type { AiAssistantAccessScope } from '../../../../interfaces/ai-assistant';
|
|
|
import { AiAssistantShareScope, type AiAssistantHasId } from '../../../../interfaces/ai-assistant';
|
|
import { AiAssistantShareScope, type AiAssistantHasId } from '../../../../interfaces/ai-assistant';
|
|
|
import { deleteAiAssistant } from '../../../services/ai-assistant';
|
|
import { deleteAiAssistant } from '../../../services/ai-assistant';
|
|
|
|
|
+import { useAiAssistantChatSidebar } from '../../../stores/ai-assistant';
|
|
|
|
|
|
|
|
import styles from './AiAssistantTree.module.scss';
|
|
import styles from './AiAssistantTree.module.scss';
|
|
|
|
|
|
|
@@ -84,6 +85,7 @@ type AiAssistantItemProps = {
|
|
|
currentUserId?: string;
|
|
currentUserId?: string;
|
|
|
aiAssistant: AiAssistantHasId;
|
|
aiAssistant: AiAssistantHasId;
|
|
|
threads: Thread[];
|
|
threads: Thread[];
|
|
|
|
|
+ onItemClicked?: (aiAssistantData: AiAssistantHasId) => void;
|
|
|
onDeleted?: () => void;
|
|
onDeleted?: () => void;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -91,13 +93,14 @@ const AiAssistantItem: React.FC<AiAssistantItemProps> = ({
|
|
|
currentUserId,
|
|
currentUserId,
|
|
|
aiAssistant,
|
|
aiAssistant,
|
|
|
threads,
|
|
threads,
|
|
|
|
|
+ onItemClicked,
|
|
|
onDeleted,
|
|
onDeleted,
|
|
|
}) => {
|
|
}) => {
|
|
|
const [isThreadsOpened, setIsThreadsOpened] = useState(false);
|
|
const [isThreadsOpened, setIsThreadsOpened] = useState(false);
|
|
|
|
|
|
|
|
- const openChatHandler = useCallback(() => {
|
|
|
|
|
- // TODO: https://redmine.weseek.co.jp/issues/159530
|
|
|
|
|
- }, []);
|
|
|
|
|
|
|
+ const openChatHandler = useCallback((aiAssistantData: AiAssistantHasId) => {
|
|
|
|
|
+ onItemClicked?.(aiAssistantData);
|
|
|
|
|
+ }, [onItemClicked]);
|
|
|
|
|
|
|
|
const openThreadsHandler = useCallback(() => {
|
|
const openThreadsHandler = useCallback(() => {
|
|
|
setIsThreadsOpened(toggle => !toggle);
|
|
setIsThreadsOpened(toggle => !toggle);
|
|
@@ -119,7 +122,7 @@ const AiAssistantItem: React.FC<AiAssistantItemProps> = ({
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
|
<li
|
|
<li
|
|
|
- onClick={openChatHandler}
|
|
|
|
|
|
|
+ onClick={() => openChatHandler(aiAssistant)}
|
|
|
role="button"
|
|
role="button"
|
|
|
className="list-group-item list-group-item-action border-0 d-flex align-items-center rounded-1"
|
|
className="list-group-item list-group-item-action border-0 d-flex align-items-center rounded-1"
|
|
|
>
|
|
>
|
|
@@ -183,6 +186,8 @@ type AiAssistantTreeProps = {
|
|
|
|
|
|
|
|
export const AiAssistantTree: React.FC<AiAssistantTreeProps> = ({ aiAssistants, onDeleted }) => {
|
|
export const AiAssistantTree: React.FC<AiAssistantTreeProps> = ({ aiAssistants, onDeleted }) => {
|
|
|
const { data: currentUser } = useCurrentUser();
|
|
const { data: currentUser } = useCurrentUser();
|
|
|
|
|
+ const { open: openAiAssistantChatSidebar } = useAiAssistantChatSidebar();
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
<ul className={`list-group ${moduleClass}`}>
|
|
<ul className={`list-group ${moduleClass}`}>
|
|
|
{aiAssistants.map(assistant => (
|
|
{aiAssistants.map(assistant => (
|
|
@@ -191,6 +196,7 @@ export const AiAssistantTree: React.FC<AiAssistantTreeProps> = ({ aiAssistants,
|
|
|
currentUserId={currentUser?._id}
|
|
currentUserId={currentUser?._id}
|
|
|
aiAssistant={assistant}
|
|
aiAssistant={assistant}
|
|
|
threads={dummyThreads}
|
|
threads={dummyThreads}
|
|
|
|
|
+ onItemClicked={openAiAssistantChatSidebar}
|
|
|
onDeleted={onDeleted}
|
|
onDeleted={onDeleted}
|
|
|
/>
|
|
/>
|
|
|
))}
|
|
))}
|