simplify form
This commit is contained in:
1 parent
b6765830a5
commit
db800e2259
1 file changed
-20
@@ -55,7 +55,6 @@ const Settings = () => {
|
||||
trigger,
|
||||
getValues,
|
||||
setValue,
|
||||
formState: { dirtyFields },
|
||||
} = form;
|
||||
useEffect(() => {
|
||||
reset(defaults, { keepDirtyValues: false });
|
||||
@@ -103,25 +102,6 @@ const Settings = () => {
|
||||
})
|
||||
);
|
||||
|
||||
// Handle password field:
|
||||
// - If emailPasswordHasBeenReset is true, ALWAYS include (even if empty to unset)
|
||||
// - Otherwise, only include if dirty (user typed something)
|
||||
if (emailPasswordHasBeenReset) {
|
||||
// Keep password field (even if empty) to allow unsetting
|
||||
// toSubmit.systemEmailPassword is already in toSubmit
|
||||
} else if (!form.formState.dirtyFields.systemEmailPassword) {
|
||||
// Not in reset mode and not dirty -> exclude (no changes)
|
||||
delete toSubmit.systemEmailPassword;
|
||||
}
|
||||
|
||||
// Handle API key field (same logic)
|
||||
if (apiKeyHasBeenReset) {
|
||||
// Keep API key field (even if empty) to allow unsetting
|
||||
} else if (!form.formState.dirtyFields.pagespeedApiKey) {
|
||||
// Not in reset mode and not dirty -> exclude (no changes)
|
||||
delete toSubmit.pagespeedApiKey;
|
||||
}
|
||||
|
||||
saveSettings(toSubmit);
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user