diff options
author | Sebastian <sebasjm@gmail.com> | 2023-05-26 17:32:33 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-05-26 17:32:33 -0300 |
commit | f5f3d3e23cac9c425c20019cb89baa212154f2ed (patch) | |
tree | 621a8dec89dd227c66121a871330259a5973b1cf /packages/exchange-backoffice-ui/src/handlers/FormProvider.tsx | |
parent | 8d85426f0e0ceec5297f43f5688d0d9bc4aa4a71 (diff) |
compute some error on submit
Diffstat (limited to 'packages/exchange-backoffice-ui/src/handlers/FormProvider.tsx')
-rw-r--r-- | packages/exchange-backoffice-ui/src/handlers/FormProvider.tsx | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/packages/exchange-backoffice-ui/src/handlers/FormProvider.tsx b/packages/exchange-backoffice-ui/src/handlers/FormProvider.tsx index 4ac90ad57..a195c2051 100644 --- a/packages/exchange-backoffice-ui/src/handlers/FormProvider.tsx +++ b/packages/exchange-backoffice-ui/src/handlers/FormProvider.tsx @@ -58,8 +58,8 @@ export function FormProvider<T>({ }: { initialValue?: Partial<T>; onUpdate?: (v: Partial<T>) => void; - onSubmit?: (v: T) => void; - computeFormState?: (v: T) => FormState<T>; + onSubmit?: (v: Partial<T>, s: FormState<T> | undefined) => void; + computeFormState?: (v: Partial<T>) => FormState<T>; children: ComponentChildren; }): VNode { // const value = useRef(initialValue ?? {}); @@ -85,7 +85,11 @@ export function FormProvider<T>({ onSubmit={(e) => { e.preventDefault(); //@ts-ignore - if (onSubmit) onSubmit(value.current); + if (onSubmit) + onSubmit( + value.current, + !computeFormState ? undefined : computeFormState(value.current), + ); }} > {children} |