visuddhinanda преди 3 години
родител
ревизия
61ab4981f4
променени са 1 файла, в които са добавени 30 реда и са изтрити 0 реда
  1. 30 0
      dashboard/src/components/comment/CommentAnchor.tsx

+ 30 - 0
dashboard/src/components/comment/CommentAnchor.tsx

@@ -0,0 +1,30 @@
+import { useEffect, useState } from "react";
+import { get } from "../../request";
+import { ICommentAnchorResponse } from "../api/Comment";
+import MdView from "../template/MdView";
+
+interface IWidget {
+  id?: string;
+}
+const Widget = ({ id }: IWidget) => {
+  const [content, setContent] = useState<string>();
+  useEffect(() => {
+    if (typeof id === "string") {
+      get<ICommentAnchorResponse>(`/v2/discussion-anchor/${id}`).then(
+        (json) => {
+          console.log(json);
+          if (json.ok) {
+            setContent(json.data);
+          }
+        }
+      );
+    }
+  }, [id]);
+  return (
+    <div>
+      <MdView html={content} />
+    </div>
+  );
+};
+
+export default Widget;