|
|
@ -85,13 +85,21 @@ const useFormUtils = < |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
const submitForm = useCallback<SubmitFormFunction>( |
|
|
|
const submitForm = useCallback<SubmitFormFunction>( |
|
|
|
({ body, getErrorMsg, msgKey = 'api', method, successMsg, url }) => { |
|
|
|
({ |
|
|
|
|
|
|
|
body, |
|
|
|
|
|
|
|
getErrorMsg, |
|
|
|
|
|
|
|
msgKey = 'api', |
|
|
|
|
|
|
|
method, |
|
|
|
|
|
|
|
setMsg = messageGroupRef?.current?.setMessage, |
|
|
|
|
|
|
|
successMsg, |
|
|
|
|
|
|
|
url, |
|
|
|
|
|
|
|
}) => { |
|
|
|
setFormSubmitting(true); |
|
|
|
setFormSubmitting(true); |
|
|
|
|
|
|
|
|
|
|
|
api |
|
|
|
api |
|
|
|
.request({ data: body, method, url }) |
|
|
|
.request({ data: body, method, url }) |
|
|
|
.then(() => { |
|
|
|
.then(() => { |
|
|
|
messageGroupRef?.current?.setMessage?.call(null, msgKey, { |
|
|
|
setMsg?.call(null, msgKey, { |
|
|
|
children: successMsg, |
|
|
|
children: successMsg, |
|
|
|
type: 'info', |
|
|
|
type: 'info', |
|
|
|
}); |
|
|
|
}); |
|
|
@ -101,7 +109,7 @@ const useFormUtils = < |
|
|
|
|
|
|
|
|
|
|
|
emsg.children = getErrorMsg(emsg.children); |
|
|
|
emsg.children = getErrorMsg(emsg.children); |
|
|
|
|
|
|
|
|
|
|
|
messageGroupRef?.current?.setMessage?.call(null, msgKey, emsg); |
|
|
|
setMsg?.call(null, msgKey, emsg); |
|
|
|
}) |
|
|
|
}) |
|
|
|
.finally(() => { |
|
|
|
.finally(() => { |
|
|
|
setFormSubmitting(false); |
|
|
|
setFormSubmitting(false); |
|
|
|