feat(ui): show smtp username and password fields when Authentication is on

This commit is contained in:
robin 2022-11-30 10:14:48 +08:00
parent 1a317d6dce
commit 665332d5d7
1 changed files with 8 additions and 9 deletions

View File

@ -169,18 +169,17 @@ const Smtp: FC = () => {
if (!setting) {
return;
}
const formState = {};
Object.keys(formData).forEach((k) => {
let v = setting[k];
if (v === null || v === undefined) {
v = '';
}
formState[k] = { ...formData[k], value: v };
const formMeta = {};
Object.keys(setting).forEach((k) => {
formMeta[k] = { ...formData[k], value: setting[k] };
});
setFormData(formState);
setFormData({ ...formData, ...formMeta });
}, [setting]);
useEffect(() => {
if (formData.smtp_authentication.value === '') {
return;
}
if (formData.smtp_authentication.value) {
setFormData({
...formData,
@ -194,7 +193,7 @@ const Smtp: FC = () => {
smtp_password: { ...formData.smtp_password, hidden: true },
});
}
}, [formData.smtp_authentication]);
}, [formData.smtp_authentication.value]);
const handleOnChange = (data) => {
setFormData(data);