This is an automated email from the ASF dual-hosted git repository. linkinstar pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/incubator-answer.git
commit d0d275a6c4bcd109428d1d60fe8fb7936261eef5 Author: Sonui <[email protected]> AuthorDate: Fri Oct 4 20:25:41 2024 +0800 style: move questionLink function to common service --- .../Detail/components/LinkedQuestions/index.tsx | 4 ++-- ui/src/services/client/question.ts | 17 ----------------- ui/src/services/common.ts | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/ui/src/pages/Questions/Detail/components/LinkedQuestions/index.tsx b/ui/src/pages/Questions/Detail/components/LinkedQuestions/index.tsx index a3a7a67a..8e5a57dd 100644 --- a/ui/src/pages/Questions/Detail/components/LinkedQuestions/index.tsx +++ b/ui/src/pages/Questions/Detail/components/LinkedQuestions/index.tsx @@ -23,7 +23,7 @@ import { Link } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { Icon } from '@/components'; -import { useQuestionLink } from '@/services'; +import { questionLink } from '@/services'; import { pathFactory } from '@/router/pathFactory'; interface Props { @@ -37,7 +37,7 @@ const Index: FC<Props> = ({ id }) => { keyPrefix: 'related_question', }); - const { data, isLoading } = useQuestionLink({ + const { data, isLoading } = questionLink({ question_id: id, page: 1, page_size: 5, diff --git a/ui/src/services/client/question.ts b/ui/src/services/client/question.ts index 34d1e75c..b62fbf1a 100644 --- a/ui/src/services/client/question.ts +++ b/ui/src/services/client/question.ts @@ -119,20 +119,3 @@ export const unDeleteQuestion = (qid) => { question_id: qid, }); }; - -export const useQuestionLink = (params: { - question_id: string; - page: number; - page_size: number; -}) => { - const apiUrl = `/answer/api/v1/question/link?${qs.stringify(params)}`; - const { data, error } = useSWR<Type.ListResult, Error>( - [apiUrl, params], - request.instance.get, - ); - return { - data, - isLoading: !data && !error, - error, - }; -}; diff --git a/ui/src/services/common.ts b/ui/src/services/common.ts index dff52cb7..ad0d99e0 100644 --- a/ui/src/services/common.ts +++ b/ui/src/services/common.ts @@ -199,6 +199,23 @@ export const questionDetail = (id: string) => { ); }; +export const questionLink = (params: { + question_id: string; + page: number; + page_size: number; +}) => { + const apiUrl = `/answer/api/v1/question/link?${qs.stringify(params)}`; + const { data, error } = useSWR<Type.ListResult, Error>( + [apiUrl, params], + request.instance.get, + ); + return { + data, + isLoading: !data && !error, + error, + }; +}; + export const getAnswers = (params: Type.AnswersReq) => { const apiUrl = `/answer/api/v1/answer/page?${qs.stringify(params)}`; return request.get<Type.ListResult<Type.AnswerItem>>(apiUrl);
