From e4e48ffab0cff7929281e7f0ce3c4c5a7cc39ea6 Mon Sep 17 00:00:00 2001 From: "haitao(lj)" Date: Fri, 3 Feb 2023 11:02:38 +0800 Subject: [PATCH] fix(Question): Optimise the display of check information for Question related form fields --- ui/src/common/interface.ts | 4 +- .../Comment/components/Form/index.tsx | 37 +++++++++---- .../Comment/components/Reply/index.tsx | 39 ++++++++++---- ui/src/components/Comment/index.tsx | 53 +++++++++---------- ui/src/pages/Questions/Ask/index.tsx | 46 ++-------------- ui/src/pages/Questions/EditAnswer/index.tsx | 2 - ui/src/utils/common.ts | 7 ++- ui/src/utils/request.ts | 10 +++- 8 files changed, 101 insertions(+), 97 deletions(-) diff --git a/ui/src/common/interface.ts b/ui/src/common/interface.ts index 1febc724..76583a8d 100644 --- a/ui/src/common/interface.ts +++ b/ui/src/common/interface.ts @@ -56,7 +56,7 @@ export interface QuestionParams { title: string; url_title?: string; content: string; - html: string; + html?: string; tags: Tag[]; } @@ -207,7 +207,7 @@ export interface AnswerItem { export interface PostAnswerReq { content: string; - html: string; + html?: string; question_id: string; } diff --git a/ui/src/components/Comment/components/Form/index.tsx b/ui/src/components/Comment/components/Form/index.tsx index 70c62fdd..bc93ddb4 100644 --- a/ui/src/components/Comment/components/Form/index.tsx +++ b/ui/src/components/Comment/components/Form/index.tsx @@ -1,5 +1,5 @@ import { useState, useEffect, memo } from 'react'; -import { Button } from 'react-bootstrap'; +import { Button, Form } from 'react-bootstrap'; import { useTranslation } from 'react-i18next'; import classNames from 'classnames'; @@ -7,7 +7,7 @@ import classNames from 'classnames'; import { TextArea, Mentions } from '@/components'; import { usePageUsers } from '@/hooks'; -const Form = ({ +const Index = ({ className = '', value: initialValue = '', onSendReply, @@ -18,7 +18,7 @@ const Form = ({ const [value, setValue] = useState(''); const pageUsers = usePageUsers(); const { t } = useTranslation('translation', { keyPrefix: 'comment' }); - + const [validationErrorMsg, setValidationErrorMsg] = useState(''); useEffect(() => { if (!initialValue) { return; @@ -32,6 +32,13 @@ const Form = ({ const handleSelected = (val) => { setValue(val); }; + const handleSendReply = () => { + onSendReply(value).catch((ex) => { + if (ex.isError) { + setValidationErrorMsg(ex.msg); + } + }); + }; return (
- -