Skip to content

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.

refactor(types): optimizing type declarations

robincdb9fa6ecd94
diff --git a/ui/src/pages/Questions/Ask/index.tsx b/ui/src/pages/Questions/Ask/index.tsx
index 0cf6dac6..f77a1545 100644
--- a/ui/src/pages/Questions/Ask/index.tsx
+++ b/ui/src/pages/Questions/Ask/index.tsx
@@ -20,49 +20,26 @@ import type * as Type from '@answer/common/interface';
import SearchQuestion from './components/SearchQuestion';
interface FormDataItem {
- title: {
- value: string;
- isInvalid: boolean;
- errorMsg: string;
- focus?: boolean;
- };
- tags: {
- value: Type.Tag[];
- isInvalid: boolean;
- errorMsg: string;
- focus?: boolean;
- };
- content: {
- value: string;
- isInvalid: boolean;
- errorMsg: string;
- focus?: boolean;
- };
- answer: {
- value: string;
- isInvalid: boolean;
- errorMsg: string;
- focus?: boolean;
- };
+ title: Type.FormValue<string>;
+ tags: Type.FormValue<Type.Tag[]>;
+ content: Type.FormValue<string>;
+ answer: Type.FormValue<string>;
}
const initFormData = {
title: {
value: '',
isInvalid: false,
errorMsg: '',
- focus: false,
},
tags: {
value: [],
isInvalid: false,
errorMsg: '',
- focus: false,
},
content: {
value: '',
isInvalid: false,
errorMsg: '',
- focus: false,
},
answer: {
value: '',
diff --git a/ui/src/pages/Questions/EditAnswer/index.tsx b/ui/src/pages/Questions/EditAnswer/index.tsx
index 0edd21ca..3f72bb52 100644
--- a/ui/src/pages/Questions/EditAnswer/index.tsx
+++ b/ui/src/pages/Questions/EditAnswer/index.tsx
@@ -17,16 +17,8 @@ import type * as Type from '@answer/common/interface';
import './index.scss';
interface FormDataItem {
- answer: {
- value: string;
- isInvalid: boolean;
- errorMsg: string;
- };
- description: {
- value: string;
- isInvalid: boolean;
- errorMsg: string;
- };
+ answer: Type.FormValue<string>;
+ description: Type.FormValue<string>;
}
const initFormData = {
answer: {
diff --git a/ui/src/pages/Tags/Edit/index.tsx b/ui/src/pages/Tags/Edit/index.tsx
index df465d72..110f2304 100644
--- a/ui/src/pages/Tags/Edit/index.tsx
+++ b/ui/src/pages/Tags/Edit/index.tsx
@@ -9,28 +9,13 @@ import classNames from 'classnames';
import { Editor, EditorRef, PageTitle } from '@answer/components';
import { useTagInfo, modifyTag, useQueryRevisions } from '@answer/api';
import { userInfoStore } from '@answer/stores';
+import type * as Type from '@answer/common/interface';
interface FormDataItem {
- displayName: {
- value: string;
- isInvalid: boolean;
- errorMsg: string;
- };
- slugName: {
- value: string;
- isInvalid: boolean;
- errorMsg: string;
- };
- description: {
- value: string;
- isInvalid: boolean;
- errorMsg: string;
- };
- editSummary: {
- value: string;
- isInvalid: boolean;
- errorMsg: string;
- };
+ displayName: Type.FormValue<string>;
+ slugName: Type.FormValue<string>;
+ description: Type.FormValue<string>;
+ editSummary: Type.FormValue<string>;
}
const initFormData = {
displayName: {