A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
fix(edit): prevent edit action if editCheck return error
haitao(lj)2b70df83f85a
diff --git a/ui/src/components/Operate/index.tsx b/ui/src/components/Operate/index.tsxindex da27b7f4..16359c91 100644--- a/ui/src/components/Operate/index.tsx+++ b/ui/src/components/Operate/index.tsx@@ -1,6 +1,6 @@import { memo, FC } from 'react';import { Button } from 'react-bootstrap';-import { Link } from 'react-router-dom';+import { Link, useNavigate } from 'react-router-dom';import { useTranslation } from 'react-i18next';import { Modal } from '@/components';@@ -31,6 +31,7 @@ const Index: FC<IProps> = ({}) => {const { t } = useTranslation('translation', { keyPrefix: 'delete' });const toast = useToast();+ const navigate = useNavigate();const reportModal = useReportModal();const closeModal = useReportModal();const editUrl =@@ -96,13 +97,14 @@ const Index: FC<IProps> = ({});}};- const handleEdit = async (evt) => {+ const handleEdit = (evt, targetUrl) => {+ evt.preventDefault();let checkObjectId = qid;if (type === 'answer') {checkObjectId = aid;}- editCheck(checkObjectId).catch(() => {- evt.preventDefault();+ editCheck(checkObjectId).then(() => {+ navigate(targetUrl);});};@@ -133,7 +135,7 @@ const Index: FC<IProps> = ({key={item.action}to={editUrl}className="link-secondary p-0 fs-14 me-3"- onClick={handleEdit}+ onClick={(evt) => handleEdit(evt, editUrl)}style={{ lineHeight: '23px' }}>{item.name}</Link>