diff options
author | Sebastian <sebasjm@gmail.com> | 2024-04-29 11:42:52 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-04-29 11:42:52 -0300 |
commit | 4ed3a05fdd97b08085e5a390963f9810b93a75fd (patch) | |
tree | 79b9a76aa3af65b83bcd4c77b42845b5c32d9af3 /packages/aml-backoffice-ui/src/hooks/form.ts | |
parent | 44308fb898372c059cf03a23ad1169d5a6e0c296 (diff) | |
download | wallet-core-4ed3a05fdd97b08085e5a390963f9810b93a75fd.tar.xz |
create form
Diffstat (limited to 'packages/aml-backoffice-ui/src/hooks/form.ts')
-rw-r--r-- | packages/aml-backoffice-ui/src/hooks/form.ts | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/packages/aml-backoffice-ui/src/hooks/form.ts b/packages/aml-backoffice-ui/src/hooks/form.ts index fae11c05c..e3d97db8c 100644 --- a/packages/aml-backoffice-ui/src/hooks/form.ts +++ b/packages/aml-backoffice-ui/src/hooks/form.ts @@ -68,11 +68,10 @@ export type FormStatus<T> = }; function constructFormHandler<T>( - form: FormValues<T>, - updateForm: (d: FormValues<T>) => void, + form: RecursivePartial<FormValues<T>>, + updateForm: (d: RecursivePartial<FormValues<T>>) => void, errors: FormErrors<T> | undefined, ): FormHandler<T> { - const keys = Object.keys(form) as Array<keyof T>; const handler = keys.reduce((prev, fieldName) => { @@ -105,17 +104,18 @@ function constructFormHandler<T>( /** * FIXME: Consider sending this to web-utils - * - * - * @param defaultValue - * @param check - * @returns + * + * + * @param defaultValue + * @param check + * @returns */ export function useFormState<T>( - defaultValue: FormValues<T>, - check: (f: FormValues<T>) => FormStatus<T>, + defaultValue: RecursivePartial<FormValues<T>>, + check: (f: RecursivePartial<FormValues<T>>) => FormStatus<T>, ): [FormHandler<T>, FormStatus<T>] { - const [form, updateForm] = useState<FormValues<T>>(defaultValue); + const [form, updateForm] = + useState<RecursivePartial<FormValues<T>>>(defaultValue); const status = check(form); const handler = constructFormHandler(form, updateForm, status.errors); |