From 55a1e8c6e1ab34702525aadf18b1acce2d06e616 Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Wed, 10 May 2023 15:01:56 -0300
Subject: fix form

---
 packages/exchange-backoffice-ui/src/forms/InputArray.tsx | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

(limited to 'packages/exchange-backoffice-ui/src/forms/InputArray.tsx')

diff --git a/packages/exchange-backoffice-ui/src/forms/InputArray.tsx b/packages/exchange-backoffice-ui/src/forms/InputArray.tsx
index f60ed4160..2447c9989 100644
--- a/packages/exchange-backoffice-ui/src/forms/InputArray.tsx
+++ b/packages/exchange-backoffice-ui/src/forms/InputArray.tsx
@@ -17,10 +17,9 @@ export function InputArray(
   const [selectedIndex, setSelected] = useState<number | undefined>(undefined);
   const selected =
     selectedIndex === undefined ? undefined : list[selectedIndex];
-  const formState = useState(selected ?? {});
+  const [subForm, updateSubForm] = useState(selected ?? {});
   useEffect(() => {
-    const [, update] = formState;
-    update(selected);
+    updateSubForm(selected);
   }, [selected]);
   return (
     <div class="sm:col-span-6">
@@ -118,7 +117,7 @@ export function InputArray(
         })}
       </div>
       {selectedIndex !== undefined && (
-        <FormProvider state={formState}>
+        <FormProvider initialValue={subForm} onUpdate={updateSubForm}>
           <div class="px-4 py-6">
             <div class="grid grid-cols-1 gap-y-8 ">
               <RenderAllFieldsByUiConfig fields={fields} />
@@ -149,8 +148,7 @@ export function InputArray(
               type="button"
               onClick={() => {
                 const newValue = [...list];
-                const [confirmed] = formState;
-                newValue.splice(selectedIndex, 1, confirmed);
+                newValue.splice(selectedIndex, 1, subForm);
                 onChange(newValue);
                 setSelected(undefined);
               }}
-- 
cgit v1.2.3

