Sfoglia il codice sorgente

add ai assistant support

visuddhinanda 1 anno fa
parent
commit
e87128a8a5
1 ha cambiato i file con 31 aggiunte e 2 eliminazioni
  1. 31 2
      dashboard-v4/dashboard/src/components/like/WatchAdd.tsx

+ 31 - 2
dashboard-v4/dashboard/src/components/like/WatchAdd.tsx

@@ -1,13 +1,21 @@
 import { useRef } from "react";
-import { ProForm, ProFormInstance } from "@ant-design/pro-components";
+import {
+  ProForm,
+  ProFormDependency,
+  ProFormInstance,
+  ProFormSelect,
+} from "@ant-design/pro-components";
 import { PlusOutlined } from "@ant-design/icons";
 
 import UserSelect from "../template/UserSelect";
 import { Button, Divider, Popover } from "antd";
 import WatchList from "./WatchList";
 import { IUser } from "../auth/User";
+import AiAssistantSelect from "../ai/AiAssistantSelect";
+import { useIntl } from "react-intl";
 
 export interface IDataType {
+  user_type?: "user" | "ai-assistant";
   user_id?: string;
 }
 
@@ -27,12 +35,33 @@ export const WatchAddButton = ({ data, onFinish }: IWidget) => {
   );
 };
 const WatchAdd = ({ data, onFinish }: IWidget) => {
+  const intl = useIntl();
   const formRef = useRef<ProFormInstance>();
   return (
     <div>
       <ProForm<IDataType> formRef={formRef} onFinish={onFinish}>
         <ProForm.Group>
-          <UserSelect name="user_id" multiple={false} />
+          <ProFormSelect
+            options={[
+              { label: "用户", value: "user" },
+              {
+                label: intl.formatMessage({ id: "labels.ai-assistant" }),
+                value: "ai-assistant",
+              },
+            ]}
+            width="xs"
+            name="userType"
+            label={"用户类型"}
+          />
+          <ProFormDependency name={["userType"]}>
+            {({ userType }) => {
+              if (userType === "user") {
+                return <UserSelect name="user_id" multiple={false} />;
+              } else {
+                return <AiAssistantSelect name="user_id" multiple={false} />;
+              }
+            }}
+          </ProFormDependency>
         </ProForm.Group>
       </ProForm>
       <Divider />