From f5f3d3e23cac9c425c20019cb89baa212154f2ed Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Fri, 26 May 2023 17:32:33 -0300
Subject: compute some error on submit

---
 packages/exchange-backoffice-ui/src/handlers/FormProvider.tsx | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

(limited to 'packages/exchange-backoffice-ui/src/handlers/FormProvider.tsx')

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}
-- 
cgit v1.2.3

