diff --git a/striker-ui/hooks/useFormUtils.ts b/striker-ui/hooks/useFormUtils.ts index ef4a8e1e..31dc7ae7 100644 --- a/striker-ui/hooks/useFormUtils.ts +++ b/striker-ui/hooks/useFormUtils.ts @@ -90,6 +90,8 @@ const useFormUtils = < getErrorMsg, msgKey = 'api', method, + onError, + onSuccess, setMsg = messageGroupRef?.current?.setMessage, successMsg, url, @@ -103,6 +105,8 @@ const useFormUtils = < children: successMsg, type: 'info', }); + + onSuccess?.call(null); }) .catch((apiError) => { const emsg = handleAPIError(apiError); @@ -110,6 +114,8 @@ const useFormUtils = < emsg.children = getErrorMsg(emsg.children); setMsg?.call(null, msgKey, emsg); + + onError?.call(null); }) .finally(() => { setFormSubmitting(false); diff --git a/striker-ui/types/FormUtils.d.ts b/striker-ui/types/FormUtils.d.ts index 9fb401db..ed185233 100644 --- a/striker-ui/types/FormUtils.d.ts +++ b/striker-ui/types/FormUtils.d.ts @@ -27,6 +27,8 @@ type SubmitFormFunction = (args: { ) => import('react').ReactNode; msgKey?: string; method: 'delete' | 'post' | 'put'; + onError?: () => void; + onSuccess?: () => void; setMsg?: import('../components/MessageGroup').MessageGroupForwardedRefContent['setMessage']; successMsg?: import('react').ReactNode; url: string;