@@ -27,85 +27,86 @@ const validateClientID = async (v) => {
2727const ClientForm = ( { clientModel, onUpdate, onSave, onCancel } ) => {
2828 const [ formErrors , setFormErrors ] = useState ( {
2929 clientId : false ,
30- redirectUris : false
31- } ) ;
30+ redirectUris : false ,
31+ } )
3232
3333 // Handle both string and array types for authorizationGrantTypes
34- let authGrantTypesArray = [ ] ;
34+ let authGrantTypesArray = [ ]
3535
3636 if ( clientModel && clientModel . authorizationGrantTypes ) {
3737 // If it's a string (from backend), split it
3838 if ( typeof clientModel . authorizationGrantTypes === 'string' ) {
3939 authGrantTypesArray = clientModel . authorizationGrantTypes
4040 . split ( ',' )
41- . map ( type => type . trim ( ) )
42- . filter ( Boolean ) ;
41+ . map ( ( type ) => type . trim ( ) )
42+ . filter ( Boolean )
4343 }
4444 // If it's already an array (from form update)
4545 else if ( Array . isArray ( clientModel . authorizationGrantTypes ) ) {
46- authGrantTypesArray = clientModel . authorizationGrantTypes ;
46+ authGrantTypesArray = clientModel . authorizationGrantTypes
4747 }
4848 }
4949
50- const grantTypes = authGrantTypesArray . reduce (
51- ( curr , prev ) => {
52- curr [ prev ] = true
53- return curr
54- } ,
55- { }
56- )
50+ const grantTypes = authGrantTypesArray . reduce ( ( curr , prev ) => {
51+ curr [ prev ] = true
52+ return curr
53+ } , { } )
5754
5855 // Format redirectUris for display in the form
59- let formattedRedirectUris = '' ;
56+ let formattedRedirectUris = ''
6057 if ( clientModel && clientModel . redirectUris ) {
6158 if ( Array . isArray ( clientModel . redirectUris ) ) {
6259 // If it's an array, join with newlines for display
63- formattedRedirectUris = clientModel . redirectUris . join ( '\n' ) ;
60+ formattedRedirectUris = clientModel . redirectUris . join ( '\n' )
6461 } else if ( typeof clientModel . redirectUris === 'string' ) {
6562 // If it's a comma-separated string, replace commas with newlines for display
66- formattedRedirectUris = clientModel . redirectUris . split ( ',' )
67- . map ( uri => uri . trim ( ) )
63+ formattedRedirectUris = clientModel . redirectUris
64+ . split ( ',' )
65+ . map ( ( uri ) => uri . trim ( ) )
6866 . filter ( Boolean )
69- . join ( '\n' ) ;
67+ . join ( '\n' )
7068 }
7169 }
7270
7371 const handleSave = ( ) => {
7472 // Check fields and show errors if needed
75- const clientIdEmpty = ! clientModel . clientId || clientModel . clientId . trim ( ) === '' ;
76- const redirectUrisEmpty = ! formattedRedirectUris || formattedRedirectUris . trim ( ) === '' ;
73+ const clientIdEmpty =
74+ ! clientModel . clientId || clientModel . clientId . trim ( ) === ''
75+ const redirectUrisEmpty =
76+ ! formattedRedirectUris || formattedRedirectUris . trim ( ) === ''
7777
7878 setFormErrors ( {
7979 clientId : clientIdEmpty ,
80- redirectUris : redirectUrisEmpty
81- } ) ;
80+ redirectUris : redirectUrisEmpty ,
81+ } )
8282
8383 // Only save if both fields are valid
8484 if ( ! clientIdEmpty && ! redirectUrisEmpty ) {
85- onSave ( ) ;
85+ onSave ( )
8686 }
87- } ;
87+ }
8888
8989 // Handle field updates and clear errors
9090 const handleFieldUpdate = ( fieldName , value ) => {
9191 // Clear the error for this field if it has a value
9292 if ( value ) {
9393 // Check if value is a string before using trim()
94- const isValid = typeof value === 'string'
95- ? value . trim ( ) . length > 0
96- : Boolean ( value ) ;
94+ const isValid =
95+ typeof value === 'string'
96+ ? value . trim ( ) . length > 0
97+ : Boolean ( value )
9798
9899 if ( isValid ) {
99- setFormErrors ( prev => ( {
100+ setFormErrors ( ( prev ) => ( {
100101 ...prev ,
101- [ fieldName ] : false
102- } ) ) ;
102+ [ fieldName ] : false ,
103+ } ) )
103104 }
104105 }
105106
106107 // Call the original onUpdate function
107- onUpdate ( fieldName , value ) ;
108- } ;
108+ onUpdate ( fieldName , value )
109+ }
109110
110111 const fields = [
111112 {
@@ -170,7 +171,9 @@ const ClientForm = ({ clientModel, onUpdate, onSave, onCancel }) => {
170171 multiLine : true ,
171172 style : formFieldStyle ,
172173 changeEvent : 'onBlur' ,
173- errorText : formErrors . redirectUris ? i18n . t ( 'This field should contain a list of URLs' ) : null ,
174+ errorText : formErrors . redirectUris
175+ ? i18n . t ( 'This field should contain a list of URLs' )
176+ : null ,
174177 } ,
175178 validators : [
176179 {
0 commit comments