@@ -23,31 +23,31 @@ import { useGetConfig } from './hooks';
23
23
import { useGetZodSchema } from './hooks' ;
24
24
25
25
export interface ReactHookFormProps {
26
- handleSubmit : ( fieldValues : FieldValues ) => void ;
27
- handleCancel : ( ) => void ;
28
- pydanticFormSchema ?: PydanticFormSchema ;
29
- isLoading : boolean ;
30
- isFullFilled : boolean ;
31
- isSending : boolean ;
32
26
apiError ?: string ;
27
+ handleCancel : ( ) => void ;
28
+ handleSubmit : ( fieldValues : FieldValues ) => void ;
33
29
hasNext : boolean ;
34
30
hasPrevious : boolean ;
35
31
initialValues : FieldValues ;
32
+ isFullFilled : boolean ;
33
+ isLoading : boolean ;
34
+ isSending : boolean ;
35
+ pydanticFormSchema ?: PydanticFormSchema ;
36
36
title ?: string ;
37
37
}
38
38
39
39
export const ReactHookForm = ( {
40
- handleSubmit ,
40
+ apiError ,
41
41
handleCancel,
42
- pydanticFormSchema,
43
- isLoading,
42
+ handleSubmit,
43
+ hasNext,
44
+ hasPrevious,
45
+ initialValues,
44
46
isFullFilled,
47
+ isLoading,
45
48
isSending,
46
- apiError,
47
- initialValues,
49
+ pydanticFormSchema,
48
50
title,
49
- hasNext,
50
- hasPrevious,
51
51
} : ReactHookFormProps ) => {
52
52
const config = useGetConfig ( ) ;
53
53
const t = useTranslations ( 'renderForm' ) ;
@@ -56,21 +56,21 @@ export const ReactHookForm = ({
56
56
< div > { t ( 'loading' ) } </ div >
57
57
) ;
58
58
59
- const ErrorComponent = config . loadingComponent ?? < div > { t ( 'error' ) } </ div > ;
59
+ const ErrorComponent = config . errorComponent ?? < div > { t ( 'error' ) } </ div > ;
60
60
61
61
const zodSchema = useGetZodSchema (
62
62
pydanticFormSchema ,
63
63
config . componentMatcherExtender ,
64
64
) ;
65
65
66
- // initialize the react-hook-form
67
66
const reactHookForm = useForm ( {
68
67
resolver : zodResolver ( zodSchema ) ,
69
68
mode : 'all' ,
70
69
values : initialValues ,
71
70
} ) ;
72
71
73
72
if ( apiError ) {
73
+ console . error ( 'API Error:' , apiError ) ;
74
74
return ErrorComponent ;
75
75
}
76
76
0 commit comments