This is an automated email from the ASF dual-hosted git repository.

shuai pushed a commit to branch feat/1.3.0/ui
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git

commit d2c53e861367c964453033a5314eddc449be936e
Author: shuai <[email protected]>
AuthorDate: Wed Mar 13 12:27:08 2024 +0800

    fix: review close action
---
 ui/src/hooks/useReportModal/index.tsx              | 34 ++++++++++++----------
 .../Review/components/ApproveDropdown/index.tsx    |  3 +-
 2 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/ui/src/hooks/useReportModal/index.tsx 
b/ui/src/hooks/useReportModal/index.tsx
index 24d26b02..88cd2442 100644
--- a/ui/src/hooks/useReportModal/index.tsx
+++ b/ui/src/hooks/useReportModal/index.tsx
@@ -38,7 +38,8 @@ interface Params {
   type: Type.ReportType;
   id: string;
   title?: string;
-  action: Type.ReportAction | 'flag_review_close';
+  action: Type.ReportAction;
+  source?: string;
 }
 
 const useReportModal = (callback?: () => void) => {
@@ -70,7 +71,11 @@ const useReportModal = (callback?: () => void) => {
   }, []);
   const getList = ({ type, action, isBackend }: Params) => {
     // @ts-ignore
-    reportList({ type, action, isBackend }).then((res) => {
+    reportList({
+      type,
+      action,
+      isBackend,
+    }).then((res) => {
       setList(res);
       setShow(true);
     });
@@ -120,6 +125,18 @@ const useReportModal = (callback?: () => void) => {
       return;
     }
     if (params.type === 'question' && params.action === 'close') {
+      if (params?.source === 'review') {
+        putFlagReviewAction({
+          flag_id: params.id,
+          operation_type: 'close_post',
+          close_type: reportType.type,
+          close_msg: content.value,
+        }).then(() => {
+          onClose();
+          asyncCallback();
+        });
+        return;
+      }
       closeQuestion({
         id: params.id,
         close_type: reportType.type,
@@ -130,19 +147,6 @@ const useReportModal = (callback?: () => void) => {
       });
       return;
     }
-
-    if (params.type === 'question' && params.action === 'flag_review_close') {
-      putFlagReviewAction({
-        flag_id: params.id,
-        operation_type: 'close_post',
-        close_type: reportType.type,
-        close_msg: content.value,
-      }).then(() => {
-        onClose();
-        asyncCallback();
-      });
-      return;
-    }
     if (!params.isBackend && params.action === 'flag') {
       rCaptcha.check(() => {
         const flagReq = {
diff --git a/ui/src/pages/Review/components/ApproveDropdown/index.tsx 
b/ui/src/pages/Review/components/ApproveDropdown/index.tsx
index 85be41db..05f92296 100644
--- a/ui/src/pages/Review/components/ApproveDropdown/index.tsx
+++ b/ui/src/pages/Review/components/ApproveDropdown/index.tsx
@@ -111,7 +111,8 @@ const Index: FC<IProps> = ({
       closeModal.onShow({
         type: 'question',
         id: itemData?.flag_id || '',
-        action: 'flag_review_close',
+        action: 'close',
+        source: 'review',
       });
     }
 

Reply via email to