fix: add form validation error feedback in agent edit dialog

- Add onFormError callback to show toast when validation fails
- This helps debug why the save button appears to do nothing
This commit is contained in:
Aibo117
2026-05-26 14:08:14 +08:00
parent 3c39e3b7e1
commit 6c0944d6f2
+11 -1
View File
@@ -266,6 +266,16 @@ function AgentEditDialogBody({
await onSubmit(buildPayload(values));
}
function onFormError(errors: object) {
console.error("Agent form validation errors:", errors)
const firstError = Object.values(errors).find(
(e: unknown) => (e as { message?: string })?.message
) as { message?: string } | undefined
if (firstError?.message) {
toast.error(firstError.message)
}
}
return (
<ProjectDialog
open={open}
@@ -284,7 +294,7 @@ function AgentEditDialogBody({
</Button>
<Button
type="button"
onClick={() => handleSubmit(onFormSubmit)()}
onClick={() => handleSubmit(onFormSubmit, onFormError)()}
disabled={saving || loading}
>
{saving ? "保存中..." : "保存"}