1- import React , { useLayoutEffect , useState } from 'react' ;
1+ import { useLayoutEffect , useState } from 'react' ;
22import { Form , notification , Spin } from 'antd' ;
33import { PropsWithChildren } from 'react' ;
44import { useMutation , useQueryClient } from '@tanstack/react-query' ;
55import { clsx } from 'clsx' ;
6- import { checkIsFormFieldsError , getErrorMessage } from '@shared/config' ;
6+ import { checkIsFormFieldsError , FormFieldError , getErrorMessage } from '@shared/config' ;
77import { useTranslation } from 'react-i18next' ;
88
99import * as classes from './styles.module.less' ;
@@ -19,6 +19,7 @@ export const ManagedForm = <T extends object, R>({
1919 keysInvalidateQueries = [ ] ,
2020 isHiddenLoadingOnSuccess = false ,
2121 onError = ( ) => undefined ,
22+ prepareFormErrors,
2223 ...props
2324} : PropsWithChildren < ManagedFormProps < T , R > > ) => {
2425 const { t, i18n } = useTranslation ( 'error' ) ;
@@ -51,7 +52,9 @@ export const ManagedForm = <T extends object, R>({
5152
5253 if ( checkIsFormFieldsError ( error ) && error . response ) {
5354 message = t ( 'formErrorHasOccurred' ) ;
54- showErrorsInFields ( form , error . response . data . error . details ) ;
55+ const errors : FormFieldError [ ] = error . response . data . error . details ;
56+ const preparedErrors = prepareFormErrors ? prepareFormErrors ( errors ) : errors ;
57+ showErrorsInFields ( form , preparedErrors ) ;
5558 }
5659
5760 notification . error ( {
0 commit comments