You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by sh...@apache.org on 2024/03/21 09:48:25 UTC

(incubator-answer) branch feat/1.3.0/ui created (now ec8f0405)

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

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


      at ec8f0405 fix: operation content may be inconsistent

This branch includes the following new commits:

     new ec8f0405 fix: operation content may be inconsistent

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(incubator-answer) 01/01: fix: operation content may be inconsistent

Posted by sh...@apache.org.
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 ec8f0405ad71dc380e06c0ef7343353bf40850b4
Author: shuai <li...@sifou.com>
AuthorDate: Thu Mar 21 17:48:10 2024 +0800

    fix: operation content may be inconsistent
---
 ui/src/hooks/useReportModal/index.tsx | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/ui/src/hooks/useReportModal/index.tsx b/ui/src/hooks/useReportModal/index.tsx
index ba17c8c2..bfe17111 100644
--- a/ui/src/hooks/useReportModal/index.tsx
+++ b/ui/src/hooks/useReportModal/index.tsx
@@ -79,16 +79,22 @@ const useReportModal = (callback?: () => void) => {
       isBackend,
     }).then((res) => {
       setList(res);
-      if (content) {
-        setReportType({
-          type: otherParams.reportType || -1,
-          haveContent: Boolean(otherParams.content),
-        });
-        setContent({
-          value: otherParams.content || '',
-          isInvalid: false,
-          errorMsg: '',
-        });
+      if (otherParams.reportType) {
+        const findType = res.find(
+          (v) => v.reason_type === otherParams.reportType,
+        );
+        if (findType) {
+          setReportType({
+            type: findType.reason_type,
+            haveContent: Boolean(findType.content_type),
+          });
+
+          setContent({
+            value: otherParams.content || '',
+            isInvalid: false,
+            errorMsg: '',
+          });
+        }
       }
       setShow(true);
     });
@@ -101,7 +107,8 @@ const useReportModal = (callback?: () => void) => {
   const handleRadio = (val) => {
     setInvalidState(false);
     setContent({
-      value: '',
+      value:
+        val.reason_type === params?.reportType ? String(params?.content) : '',
       isInvalid: false,
       errorMsg: '',
     });