Shun Miyazawa 1 год назад
Родитель
Сommit
b554ad75ed

+ 3 - 1
apps/app/src/features/openai/client/components/AiAssistant/Sidebar/AiAssistantSubstance.tsx

@@ -41,7 +41,9 @@ export const AiAssistantContent = (): JSX.Element => {
             チームアシスタント
             チームアシスタント
           </h3>
           </h3>
           {aiAssistants?.teamAiAssistants != null && aiAssistants.teamAiAssistants.length !== 0 && (
           {aiAssistants?.teamAiAssistants != null && aiAssistants.teamAiAssistants.length !== 0 && (
-            <AiAssistantTree aiAssistants={aiAssistants.teamAiAssistants} />
+            <AiAssistantTree
+              aiAssistants={aiAssistants.teamAiAssistants}
+            />
           )}
           )}
         </div>
         </div>
       </div>
       </div>

+ 35 - 18
apps/app/src/features/openai/client/components/AiAssistant/Sidebar/AiAssistantTree.tsx

@@ -9,28 +9,46 @@ 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';
 
 
-type ThreadItemProps = {
+
+type Thread = {
+  _id: string;
   name: string;
   name: string;
+}
+
+const dummyThreads: Thread[] = [
+  { _id: '1', name: 'thread1' },
+  { _id: '2', name: 'thread2' },
+  { _id: '3', name: 'thread3' },
+];
+
+type ThreadItemProps = {
+  thread: Thread;
 };
 };
 
 
 const ThreadItem: React.FC<ThreadItemProps> = ({
 const ThreadItem: React.FC<ThreadItemProps> = ({
-  name,
+  thread,
 }) => {
 }) => {
 
 
   const deleteThreadHandler = useCallback(() => {
   const deleteThreadHandler = useCallback(() => {
-    //
+    // TODO: https://redmine.weseek.co.jp/issues/161490
+  }, []);
+
+  const openChatHandler = useCallback(() => {
+    // TODO: https://redmine.weseek.co.jp/issues/159530
   }, []);
   }, []);
 
 
   return (
   return (
     <li
     <li
+      role="button"
       className="list-group-item list-group-item-action border-0 d-flex align-items-center rounded-1 ps-5"
       className="list-group-item list-group-item-action border-0 d-flex align-items-center rounded-1 ps-5"
+      onClick={openChatHandler}
     >
     >
       <div>
       <div>
         <span className="material-symbols-outlined fs-5">chat</span>
         <span className="material-symbols-outlined fs-5">chat</span>
       </div>
       </div>
 
 
       <div className="grw-ai-assistant-title-anchor ps-1">
       <div className="grw-ai-assistant-title-anchor ps-1">
-        <p className="text-truncate m-auto">{name}</p>
+        <p className="text-truncate m-auto">{thread.name}</p>
       </div>
       </div>
 
 
       <div className="grw-ai-assistant-actions opacity-0 d-flex justify-content-center ">
       <div className="grw-ai-assistant-actions opacity-0 d-flex justify-content-center ">
@@ -62,7 +80,7 @@ const getShareScopeIcon = (shareScope: AiAssistantShareScope, accessScope: AiAss
 type AiAssistantItemProps = {
 type AiAssistantItemProps = {
   currentUserId?: string;
   currentUserId?: string;
   aiAssistant: AiAssistantHasId;
   aiAssistant: AiAssistantHasId;
-  threads: { id: string; name: string }[]; // dummy data
+  threads: Thread[];
   onDeleted?: () => void;
   onDeleted?: () => void;
 };
 };
 
 
@@ -74,11 +92,15 @@ const AiAssistantItem: React.FC<AiAssistantItemProps> = ({
 }) => {
 }) => {
   const [isThreadsOpened, setIsThreadsOpened] = useState(false);
   const [isThreadsOpened, setIsThreadsOpened] = useState(false);
 
 
-  const clickOpenThreadHandler = useCallback(() => {
+  const openChatHandler = useCallback(() => {
+    // TODO: https://redmine.weseek.co.jp/issues/159530
+  }, []);
+
+  const openThreadsHandler = useCallback(() => {
     setIsThreadsOpened(toggle => !toggle);
     setIsThreadsOpened(toggle => !toggle);
   }, []);
   }, []);
 
 
-  const clickDeleteAiAssistantHandler = useCallback(async() => {
+  const deleteAiAssistantHandler = useCallback(async() => {
     try {
     try {
       await deleteAiAssistant(aiAssistant._id);
       await deleteAiAssistant(aiAssistant._id);
       onDeleted?.();
       onDeleted?.();
@@ -94,12 +116,14 @@ const AiAssistantItem: React.FC<AiAssistantItemProps> = ({
   return (
   return (
     <div className="grw-ai-assistant-item-container">
     <div className="grw-ai-assistant-item-container">
       <li
       <li
+        onClick={openChatHandler}
+        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"
       >
       >
         <div className="d-flex justify-content-center">
         <div className="d-flex justify-content-center">
           <button
           <button
             type="button"
             type="button"
-            onClick={clickOpenThreadHandler}
+            onClick={openThreadsHandler}
             className={`grw-ai-assistant-triangle-btn btn px-0 ${isThreadsOpened ? 'grw-ai-assistant-open' : ''}`}
             className={`grw-ai-assistant-triangle-btn btn px-0 ${isThreadsOpened ? 'grw-ai-assistant-open' : ''}`}
           >
           >
             <div className="d-flex justify-content-center">
             <div className="d-flex justify-content-center">
@@ -127,7 +151,7 @@ const AiAssistantItem: React.FC<AiAssistantItemProps> = ({
             <button
             <button
               type="button"
               type="button"
               className="btn btn-link text-secondary p-0"
               className="btn btn-link text-secondary p-0"
-              onClick={clickDeleteAiAssistantHandler}
+              onClick={deleteAiAssistantHandler}
             >
             >
               <span className="material-symbols-outlined fs-5">delete</span>
               <span className="material-symbols-outlined fs-5">delete</span>
             </button>
             </button>
@@ -139,8 +163,8 @@ const AiAssistantItem: React.FC<AiAssistantItemProps> = ({
         <div className="grw-ai-assistant-item-children">
         <div className="grw-ai-assistant-item-children">
           {threads.map(thread => (
           {threads.map(thread => (
             <ThreadItem
             <ThreadItem
-              key={thread.id}
-              name={thread.name}
+              key={thread._id}
+              thread={thread}
             />
             />
           ))}
           ))}
         </div>
         </div>
@@ -149,13 +173,6 @@ const AiAssistantItem: React.FC<AiAssistantItemProps> = ({
   );
   );
 };
 };
 
 
-
-const dummyThreads = [
-  { id: '1', name: 'thread1' },
-  { id: '2', name: 'thread2' },
-  { id: '3', name: 'thread3' },
-];
-
 type AiAssistantTreeProps = {
 type AiAssistantTreeProps = {
   aiAssistants: AiAssistantHasId[];
   aiAssistants: AiAssistantHasId[];
   onDeleted?: () => void;
   onDeleted?: () => void;