Browse Source

add onReady

visuddhinanda 2 years ago
parent
commit
410c6bba72
1 changed files with 7 additions and 1 deletions
  1. 7 1
      dashboard/src/components/discussion/DiscussionTopicInfo.tsx

+ 7 - 1
dashboard/src/components/discussion/DiscussionTopicInfo.tsx

@@ -10,8 +10,9 @@ const { Title, Text } = Typography;
 
 interface IWidget {
   topicId?: string;
+  onReady?: Function;
 }
-const DiscussionTopicInfoWidget = ({ topicId }: IWidget) => {
+const DiscussionTopicInfoWidget = ({ topicId, onReady }: IWidget) => {
   const [data, setData] = useState<IComment>();
   useEffect(() => {
     if (typeof topicId === "undefined") {
@@ -27,6 +28,7 @@ const DiscussionTopicInfoWidget = ({ topicId }: IWidget) => {
             id: item.id,
             resId: item.res_id,
             resType: item.res_type,
+            parent: item.parent,
             user: item.editor,
             title: item.title,
             content: item.content,
@@ -34,6 +36,10 @@ const DiscussionTopicInfoWidget = ({ topicId }: IWidget) => {
             updatedAt: item.updated_at,
           };
           setData(discussion);
+          if (typeof onReady !== "undefined") {
+            console.log("on ready");
+            onReady(discussion);
+          }
         } else {
           message.error(json.message);
         }