File tree 2 files changed +15
-5
lines changed
2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ interface Props {
16
16
disabled : boolean ;
17
17
isSubmitting : boolean ;
18
18
handleSubmit : React . MouseEventHandler < HTMLButtonElement > ;
19
- handleCancel : React . MouseEventHandler < HTMLButtonElement > ;
19
+ handleCancel ? : React . MouseEventHandler < HTMLButtonElement > ;
20
20
}
21
21
22
22
export const SubmitButton : FC < Props > = ( {
@@ -37,9 +37,11 @@ export const SubmitButton: FC<Props> = ({
37
37
{ name }
38
38
{ isSubmitting && < CircularProgress size = "20px" /> }
39
39
</ StyledButton >
40
- < StyledButton variant = "contained" color = "info" onClick = { handleCancel } >
41
- キャンセル
42
- </ StyledButton >
40
+ { handleCancel && (
41
+ < StyledButton variant = "contained" color = "info" onClick = { handleCancel } >
42
+ キャンセル
43
+ </ StyledButton >
44
+ ) }
43
45
</ StyledBox >
44
46
) ;
45
47
} ;
Original file line number Diff line number Diff line change @@ -118,7 +118,15 @@ export const extractAPIException = async <T>(
118
118
const details = ( typed as Record < string , Array < ErrorDetail > > ) [ fieldName ] ;
119
119
const message = details . map ( ( e ) => extractErrorDetail ( e ) ) . join ( ", " ) ;
120
120
121
- fieldReporter ( fieldName as keyof T , message ) ;
121
+ // This convert snake_case to camelCase (e.g. "nw_addr" -> "nwAddr")
122
+ const snakeToCamel = ( x : string ) =>
123
+ x
124
+ . toLowerCase ( )
125
+ . replace ( / ( _ \w ) / g, ( m : string ) => m . toUpperCase ( ) . substr ( 1 ) ) ;
126
+
127
+ // It's necessary to convert fieldName from snake case to cammel case because
128
+ // server-side response its name as snake case but zod expect it as camel case.
129
+ fieldReporter ( snakeToCamel ( fieldName ) as keyof T , message ) ;
122
130
} ) ;
123
131
} ;
124
132
You can’t perform that action at this time.
0 commit comments