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 (
- -