Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Alias change cb signatures

dominik-zeglen498b8dfadc5f
diff --git a/saleor/static/dashboard-next/hooks/useForm.ts b/saleor/static/dashboard-next/hooks/useForm.ts
index fcd28c3dc2..8b1d27b8e6 100644
--- a/saleor/static/dashboard-next/hooks/useForm.ts
+++ b/saleor/static/dashboard-next/hooks/useForm.ts
@@ -12,14 +12,17 @@ export interface ChangeEvent<TName = string, TData = any> {
};
}
+export type FormChange = (event: ChangeEvent<T>, cb?: () => void) => void;
+
export interface UseFormResult<T> {
- change: (event: ChangeEvent<T>, cb?: () => void) => void;
+ change: FormChange;
data: T;
errors: Record<string, string>;
hasChanged: boolean;
reset: () => void;
set: (data: T) => void;
submit: () => void;
+ triggerChange: () => void;
toggleValue: (event: ChangeEvent<T>) => void;
}
@@ -112,6 +115,10 @@ function useForm<T extends FormData>(
return onSubmit(data);
}
+ function triggerChange() {
+ setChanged(true);
+ }
+
return {
change,
data,
@@ -120,7 +127,8 @@ function useForm<T extends FormData>(
reset,
set,
submit,
- toggleValue
+ toggleValue,
+ triggerChange
};
}
diff --git a/saleor/static/dashboard-next/hooks/useFormset.ts b/saleor/static/dashboard-next/hooks/useFormset.ts
index 3f9e15f57c..c8dcadf606 100644
--- a/saleor/static/dashboard-next/hooks/useFormset.ts
+++ b/saleor/static/dashboard-next/hooks/useFormset.ts
@@ -1,5 +1,6 @@
import { useEffect, useState } from "react";
+export type FormsetChange = (id: string, value: string) => void;
export interface FormsetAtomicData<TData = object> {
data: TData;
id: string;
@@ -8,7 +9,7 @@ export interface FormsetAtomicData<TData = object> {
}
export type FormsetData<TData = object> = Array<FormsetAtomicData<TData>>;
export interface UseFormsetOutput<TData = object> {
- change: (id: string, value: string) => void;
+ change: FormsetChange;
data: FormsetData<TData>;
}
function useFormset<TData = object>(