Merge branch 'feat/ui-v0.4' of git.backyard.segmentfault.com:opensource/answer into feat/ui-v0.4

This commit is contained in:
haitao(lj) 2022-11-18 16:05:24 +08:00
commit 701beb0de6
6 changed files with 16 additions and 12 deletions

View File

@ -507,6 +507,7 @@ ui:
search_tag: Search tag
hint: "Describe what your question is about, at least one tag is required."
no_result: No tags matched
tag_required_text: Required tag (at least one)
header:
nav:
question: Questions

View File

@ -19,6 +19,7 @@ interface IProps {
onBlur?: () => void;
hiddenDescription?: boolean;
hiddenCreateBtn?: boolean;
showRequiredTagText?: boolean;
alwaysShowAddBtn?: boolean;
}
@ -32,6 +33,7 @@ const TagSelector: FC<IProps> = ({
hiddenDescription = false,
hiddenCreateBtn = false,
alwaysShowAddBtn = false,
showRequiredTagText = false,
}) => {
const [initialValue, setInitialValue] = useState<Type.Tag[]>([...value]);
const [currentIndex, setCurrentIndex] = useState<number>(0);
@ -224,12 +226,14 @@ const TagSelector: FC<IProps> = ({
</Form>
</Dropdown.Header>
)}
{tags && tags.filter((v) => v.recommend)?.length > 0 && (
{showRequiredTagText &&
tags &&
tags.filter((v) => v.recommend)?.length > 0 && (
<Dropdown.Item
disabled
style={{ fontWeight: 500 }}
className="text-secondary">
Required tag (at least one)
{t('tag_required_text')}
</Dropdown.Item>
)}

View File

@ -60,7 +60,7 @@ const Index: React.FC<IProps> = ({ visible = false }) => {
})
.catch((err) => {
if (err.isError) {
const data = handleFormError(err.list, formData);
const data = handleFormError(err, formData);
setFormData({ ...data });
}
})

View File

@ -115,7 +115,7 @@ const Index: FC = () => {
})
.catch((err) => {
if (err.isError) {
const data = handleFormError(err.list, formData);
const data = handleFormError(err, formData);
setFormData({ ...data });
}
});

View File

@ -348,6 +348,7 @@ const Ask = () => {
<TagSelector
value={formData.tags.value}
onChange={handleTagsChange}
showRequiredTagText
/>
<Form.Control.Feedback type="invalid">
{formData.tags.errorMsg}

View File

@ -130,9 +130,7 @@ const Index: React.FC = () => {
// }
// }
if (err.isError) {
console.log('err===', err);
const data = handleFormError(err, formData);
console.log('err===', data);
if (err.list.filter((v) => v.error_field.indexOf('captcha') < 0)) {
setModalState(false);
}