Merge branch 'ui' of git.backyard.segmentfault.com:opensource/answer into ui

This commit is contained in:
haitao(lj) 2022-09-30 10:00:51 +08:00
commit ff6cf2db03
3 changed files with 37 additions and 9 deletions

View File

@ -102,10 +102,7 @@ const TagSelector: FC<IProps> = ({
}
queryTags(tag).then((res) => {
if (!res) {
return;
}
const tagArray: Type.Tag[] = filterTags(res);
const tagArray: Type.Tag[] = filterTags(res || []);
setTags(tagArray);
});
}, [tag]);

View File

@ -7,6 +7,7 @@ import ReactDOM from 'react-dom/client';
const div = document.createElement('div');
const root = ReactDOM.createRoot(div);
const MAX_LENGTH = 35;
interface IProps {
title?: string;
onConfirm?: (formData: any) => void;
@ -44,13 +45,41 @@ const useTagModal = (props: IProps = {}) => {
const checkValidated = (): boolean => {
let bol = true;
const { slugName } = formData;
const { displayName, slugName } = formData;
if (!displayName.value) {
bol = false;
formData.displayName = {
value: '',
isInvalid: true,
errorMsg: t('form.fields.display_name.msg.empty'),
};
} else if (displayName.value.length > MAX_LENGTH) {
bol = false;
formData.displayName = {
value: '',
isInvalid: true,
errorMsg: t('form.fields.display_name.msg.range'),
};
} else {
formData.displayName = {
value: displayName.value,
isInvalid: false,
errorMsg: '',
};
}
if (!slugName.value) {
bol = false;
formData.slugName = {
value: '',
isInvalid: true,
errorMsg: t('form.fields.slugName.msg.empty'),
errorMsg: t('form.fields.slug_name.msg.empty'),
};
} else if (slugName.value.length > MAX_LENGTH) {
bol = false;
formData.slugName = {
value: '',
isInvalid: true,
errorMsg: t('form.fields.slug_name.msg.range'),
};
} else {
formData.slugName = {

View File

@ -208,14 +208,16 @@
"display_name": {
"label": "Display name",
"msg": {
"empty": "Display name cannot be empty."
"empty": "Display name cannot be empty.",
"range": "Display name up to 35 characters"
}
},
"slug_name": {
"label": "URL slug",
"description": "Spaces are not allowed, please use '-' instead.",
"msg": {
"empty": "Please enter a name for the tag."
"empty": "Please enter a name for the tag.",
"range": "URL slug up to 35 characters"
}
},
"description": {
@ -868,4 +870,4 @@
}
}
}
}
}