mirror of
https://git.boos.lat/aibo/BossChat.git
synced 2026-10-30 07:06:08 +00:00
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:
@@ -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 ? "保存中..." : "保存"}
|
||||
|
||||
Reference in New Issue
Block a user