aboutsummaryrefslogtreecommitdiff
path: root/packages/aml-backoffice-ui/src/hooks/form.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/aml-backoffice-ui/src/hooks/form.ts')
-rw-r--r--packages/aml-backoffice-ui/src/hooks/form.ts22
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);