diff --git a/ui/src/pages/Questions/Detail/components/Answer/index.tsx b/ui/src/pages/Questions/Detail/components/Answer/index.tsx index ebb7d8a6..dfbefa3d 100644 --- a/ui/src/pages/Questions/Detail/components/Answer/index.tsx +++ b/ui/src/pages/Questions/Detail/components/Answer/index.tsx @@ -1,5 +1,5 @@ import { memo, FC, useEffect, useRef } from 'react'; -import { Button, Alert } from 'react-bootstrap'; +import { Button, Alert, Badge } from 'react-bootstrap'; import { useTranslation } from 'react-i18next'; import { Link, useSearchParams } from 'react-router-dom'; @@ -20,8 +20,7 @@ interface Props { data: AnswerItem; /** router answer id */ aid?: string; - /** is author */ - isAuthor: boolean; + canAccept: boolean; questionTitle: string; slugTitle: string; isLogged: boolean; @@ -30,11 +29,11 @@ interface Props { const Index: FC = ({ aid, data, - isAuthor, isLogged, questionTitle = '', slugTitle, callback, + canAccept = false, }) => { const { t } = useTranslation('translation', { keyPrefix: 'question_detail', @@ -77,6 +76,14 @@ const Index: FC = ({ {t('post_deleted', { keyPrefix: 'messages' })} )} + {data?.accepted === 2 && ( +
+ + + Best answer + +
+ )}
= ({ }} /> - {data?.accepted === 2 && ( + {canAccept && ( - )} - - {isAuthor && data.accepted === 1 && ( - )} diff --git a/ui/src/pages/Questions/Detail/index.tsx b/ui/src/pages/Questions/Detail/index.tsx index 479fa5b7..7397c527 100644 --- a/ui/src/pages/Questions/Detail/index.tsx +++ b/ui/src/pages/Questions/Detail/index.tsx @@ -56,6 +56,7 @@ const Index = () => { const userInfo = loggedUserInfoStore((state) => state.user); const isAuthor = userInfo?.username === question?.user_info?.username; const isAdmin = userInfo?.role_id === 2; + const isModerator = userInfo?.role_id === 3; const isLogged = Boolean(userInfo?.access_token); const loggedUserRank = userInfo?.rank; const { state: locationState } = useLocation(); @@ -222,7 +223,7 @@ const Index = () => { data={item} questionTitle={question?.title || ''} slugTitle={question?.url_title} - isAuthor={isAuthor} + canAccept={isAuthor || isAdmin || isModerator} callback={initPage} isLogged={isLogged} />