visuddhinanda hace 3 años
padre
commit
d9c8711530
Se han modificado 1 ficheros con 58 adiciones y 0 borrados
  1. 58 0
      dashboard/src/components/term/TermModal.tsx

+ 58 - 0
dashboard/src/components/term/TermModal.tsx

@@ -0,0 +1,58 @@
+import { useState } from "react";
+import { Modal } from "antd";
+import TermEdit from "./TermEdit";
+
+interface IWidget {
+  trigger?: React.ReactNode;
+  id?: string;
+  word?: string;
+  studioName?: string;
+  channelId?: string;
+  onUpdate?: Function;
+}
+const Widget = ({
+  trigger,
+  id,
+  word,
+  studioName,
+  channelId,
+  onUpdate,
+}: IWidget) => {
+  const [isModalOpen, setIsModalOpen] = useState(false);
+
+  const showModal = () => {
+    setIsModalOpen(true);
+  };
+
+  const handleOk = () => {
+    setIsModalOpen(false);
+  };
+
+  const handleCancel = () => {
+    setIsModalOpen(false);
+  };
+
+  return (
+    <>
+      <span onClick={showModal}>{trigger}</span>
+      <Modal
+        width={760}
+        title="术语"
+        destroyOnClose={true}
+        open={isModalOpen}
+        onOk={handleOk}
+        onCancel={handleCancel}
+      >
+        <TermEdit
+          id={id}
+          word={word}
+          studioName={studioName}
+          channelId={channelId}
+          onUpdate={handleOk}
+        />
+      </Modal>
+    </>
+  );
+};
+
+export default Widget;