Просмотр исходного кода

Refactor AiAssistantItem props

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

+ 5 - 11
apps/app/src/features/openai/client/components/AiAssistant/Sidebar/AiAssistantTree.tsx

@@ -39,16 +39,12 @@ const getShareScopeIcon = (shareScope: AiAssistantShareScope, accessScope: AiAss
 };
 };
 
 
 type AiAssistantItemProps = {
 type AiAssistantItemProps = {
-  name: string;
-  shareScope: AiAssistantShareScope;
-  accessScope: AiAssistantAccessScope;
+  aiAssistant: AiAssistantHasId;
   threads: { id: string; name: string }[]; // dummy data
   threads: { id: string; name: string }[]; // dummy data
 };
 };
 
 
 const AiAssistantItem: React.FC<AiAssistantItemProps> = ({
 const AiAssistantItem: React.FC<AiAssistantItemProps> = ({
-  name,
-  shareScope,
-  accessScope,
+  aiAssistant,
   threads,
   threads,
 }) => {
 }) => {
   const [isExpanded, setIsExpanded] = useState(false);
   const [isExpanded, setIsExpanded] = useState(false);
@@ -75,10 +71,10 @@ const AiAssistantItem: React.FC<AiAssistantItemProps> = ({
           </button>
           </button>
         </div>
         </div>
         <div>
         <div>
-          <span className="material-symbols-outlined fs-5">{getShareScopeIcon(shareScope, accessScope)}</span>
+          <span className="material-symbols-outlined fs-5">{getShareScopeIcon(aiAssistant.shareScope, aiAssistant.accessScope)}</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">{aiAssistant.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 ">
@@ -128,9 +124,7 @@ export const AiAssistantTree: React.FC<AiAssistantTreeProps> = ({ aiAssistants }
       {aiAssistants.map(assistant => (
       {aiAssistants.map(assistant => (
         <AiAssistantItem
         <AiAssistantItem
           key={assistant._id}
           key={assistant._id}
-          name={assistant.name}
-          shareScope={assistant.shareScope}
-          accessScope={assistant.accessScope}
+          aiAssistant={assistant}
           threads={dummyThreads}
           threads={dummyThreads}
         />
         />
       ))}
       ))}