diff --git a/web/src/pages/agent/gobal-variable-sheet/hooks/use-form.tsx b/web/src/pages/agent/gobal-variable-sheet/hooks/use-form.tsx index cb38012f3..54d37957a 100644 --- a/web/src/pages/agent/gobal-variable-sheet/hooks/use-form.tsx +++ b/web/src/pages/agent/gobal-variable-sheet/hooks/use-form.tsx @@ -15,27 +15,30 @@ export const useHandleForm = () => { return value; } }; - const handleSubmit = useCallback(async (fieldValue: FieldValues) => { - const param = { - ...(data.dsl?.variables || {}), - [fieldValue.name]: { - ...fieldValue, - value: - fieldValue.type === TypesWithArray.Object || - fieldValue.type === TypesWithArray.ArrayObject - ? handleObjectData(fieldValue.value) - : fieldValue.value, - }, - } as Record; + const handleSubmit = useCallback( + async (fieldValue: FieldValues) => { + const param = { + ...(data.dsl?.variables || {}), + [fieldValue.name]: { + ...fieldValue, + value: + fieldValue.type === TypesWithArray.Object || + fieldValue.type === TypesWithArray.ArrayObject + ? handleObjectData(fieldValue.value) + : fieldValue.value, + }, + } as Record; - const res = await saveGraph(undefined, { - globalVariables: param, - }); + const res = await saveGraph(undefined, { + globalVariables: param, + }); - if (res.code === 0) { - refetch(); - } - }, []); + if (res.code === 0) { + refetch(); + } + }, + [data.dsl?.variables, refetch, saveGraph], + ); return { handleSubmit, loading }; };