@@ -12,7 +12,7 @@ import {
1212 FormControl ,
1313 MenuItem ,
1414 Select ,
15- SelectChangeEvent ,
15+ type SelectChangeEvent ,
1616} from '@mui/material' ;
1717import SearchIcon from '@mui/icons-material/Search' ;
1818import { useState } from 'react' ;
@@ -37,11 +37,11 @@ export default function GbfsFeedSearchInput(): React.ReactElement {
3737 const [ oauthClientSecret , setOauthClientSecret ] = useState < string > ( '' ) ;
3838 const [ oauthTokenUrl , setOauthTokenUrl ] = useState < string > ( '' ) ;
3939
40- const handleChange = ( event : React . ChangeEvent < HTMLInputElement > ) => {
40+ const handleChange = ( event : React . ChangeEvent < HTMLInputElement > ) : void => {
4141 setRequiresAuth ( event . target . checked ) ;
4242 } ;
4343
44- const handleAuthTypeChange = ( event : SelectChangeEvent < string > ) => {
44+ const handleAuthTypeChange = ( event : SelectChangeEvent < string > ) : void => {
4545 setAuthType ( event . target . value ) ;
4646 setBasicAuthUsername ( '' ) ;
4747 setBasicAuthPassword ( '' ) ;
@@ -52,17 +52,21 @@ export default function GbfsFeedSearchInput(): React.ReactElement {
5252 } ;
5353
5454 const isSubmitBoxDisabled = ( ) : boolean => {
55- if ( ! autoDiscoveryUrlInput ) return true ;
55+ if ( autoDiscoveryUrlInput === '' ) return true ;
5656 if ( requiresAuth ) {
57- if ( ! authType ) return true ;
57+ if ( authType === '' ) return true ;
5858 if ( authType === AuthTypeEnum . BASIC ) {
59- if ( ! basicAuthUsername || ! basicAuthPassword ) return true ;
59+ if ( basicAuthUsername === '' || basicAuthPassword === '' ) return true ;
6060 }
6161 if ( authType === AuthTypeEnum . BEARER ) {
62- if ( ! bearerAuthValue ) return true ;
62+ if ( bearerAuthValue === '' ) return true ;
6363 }
6464 if ( authType === AuthTypeEnum . OAUTH ) {
65- if ( ! oauthClientId || ! oauthClientSecret || ! oauthTokenUrl )
65+ if (
66+ oauthClientId === '' ||
67+ oauthClientSecret === '' ||
68+ oauthTokenUrl === ''
69+ )
6670 return true ;
6771 }
6872 }
@@ -73,13 +77,11 @@ export default function GbfsFeedSearchInput(): React.ReactElement {
7377 // 1. dispatch action with url and auth details (state -> loading)
7478 // once done then
7579 // 2. navigate to /gbfs-validator?AutoDiscoveryUrl=url
76-
7780 // or
78-
7981 // navigate to /gbfs-validator?AutoDiscoveryUrl=url&auth details
8082 // store the auth details in context
8183 // let the GbfsValidator component handle the loading state
82- }
84+ } ;
8385
8486 return (
8587 < Box
@@ -99,16 +101,18 @@ export default function GbfsFeedSearchInput(): React.ReactElement {
99101 display : 'flex' ,
100102 justifyContent : 'space-between' ,
101103 alignItems : 'center' ,
102- p : { xs : 0 }
104+ p : { xs : 0 } ,
103105 } }
104106 >
105107 < TextField
106108 variant = 'outlined'
107109 placeholder = 'eg: https://example.com/gbfs.json'
108110 sx = { { width : '100%' , mr : 2 } }
109- onChange = { ( e ) => setAutoDiscoveryUrlInput ( e . target . value ) }
111+ onChange = { ( e ) => {
112+ setAutoDiscoveryUrlInput ( e . target . value ) ;
113+ } }
110114 InputProps = { {
111- startAdornment : < SearchIcon sx = { { mr :1 } } > </ SearchIcon > ,
115+ startAdornment : < SearchIcon sx = { { mr : 1 } } > </ SearchIcon > ,
112116 } }
113117 />
114118 < Button
@@ -121,7 +125,9 @@ export default function GbfsFeedSearchInput(): React.ReactElement {
121125 ) } `}
122126 disabled = { isSubmitBoxDisabled ( ) }
123127 type = 'submit'
124- onClick = { ( ) => validateGBFSFeed ( ) }
128+ onClick = { ( ) => {
129+ validateGBFSFeed ( ) ;
130+ } }
125131 >
126132 Validate
127133 </ Button >
@@ -144,20 +150,24 @@ export default function GbfsFeedSearchInput(): React.ReactElement {
144150 </ MenuItem >
145151 < MenuItem value = { AuthTypeEnum . BASIC } > Basic Auth</ MenuItem >
146152 < MenuItem value = { AuthTypeEnum . BEARER } > Bearer Token</ MenuItem >
147- < MenuItem value = { AuthTypeEnum . OAUTH } > Oauth Client Credentials Grant</ MenuItem >
153+ < MenuItem value = { AuthTypeEnum . OAUTH } >
154+ Oauth Client Credentials Grant
155+ </ MenuItem >
148156 </ Select >
149157 </ FormControl >
150158 ) }
151159
152160 { requiresAuth && authType === AuthTypeEnum . BASIC && (
153- < Box sx = { { display : 'flex' , gap : 2 , mt : 2 , } } >
161+ < Box sx = { { display : 'flex' , gap : 2 , mt : 2 } } >
154162 < TextField
155163 size = 'small'
156164 variant = 'outlined'
157165 label = 'Username'
158166 placeholder = 'Enter Username'
159167 fullWidth
160- onChange = { ( e ) => setBasicAuthUsername ( e . target . value ) }
168+ onChange = { ( e ) => {
169+ setBasicAuthUsername ( e . target . value ) ;
170+ } }
161171 />
162172 < TextField
163173 size = 'small'
@@ -166,7 +176,9 @@ export default function GbfsFeedSearchInput(): React.ReactElement {
166176 placeholder = 'Enter Password'
167177 type = 'password'
168178 fullWidth
169- onChange = { ( e ) => setBasicAuthPassword ( e . target . value ) }
179+ onChange = { ( e ) => {
180+ setBasicAuthPassword ( e . target . value ) ;
181+ } }
170182 />
171183 </ Box >
172184 ) }
@@ -179,36 +191,43 @@ export default function GbfsFeedSearchInput(): React.ReactElement {
179191 placeholder = 'Enter Bearer Token'
180192 sx = { { mt : 2 } }
181193 fullWidth
182- onChange = { ( e ) => setBearerAuthValue ( e . target . value ) }
183-
194+ onChange = { ( e ) => {
195+ setBearerAuthValue ( e . target . value ) ;
196+ } }
184197 />
185198 ) }
186199
187200 { requiresAuth && authType === AuthTypeEnum . OAUTH && (
188- < Box sx = { { display : 'flex' , gap : 2 , mt : 2 , } } >
201+ < Box sx = { { display : 'flex' , gap : 2 , mt : 2 } } >
189202 < TextField
190203 size = 'small'
191204 variant = 'outlined'
192205 placeholder = 'Client Id'
193206 label = 'Client Id'
194207 fullWidth
195- onChange = { ( e ) => setOauthClientId ( e . target . value ) }
208+ onChange = { ( e ) => {
209+ setOauthClientId ( e . target . value ) ;
210+ } }
196211 />
197212 < TextField
198213 size = 'small'
199214 variant = 'outlined'
200215 placeholder = 'Enter Client Secret'
201216 label = 'Client Secret'
202217 fullWidth
203- onChange = { ( e ) => setOauthClientSecret ( e . target . value ) }
218+ onChange = { ( e ) => {
219+ setOauthClientSecret ( e . target . value ) ;
220+ } }
204221 />
205222 < TextField
206223 size = 'small'
207224 variant = 'outlined'
208225 placeholder = 'Enter Token Url'
209226 label = 'Token Url'
210227 fullWidth
211- onChange = { ( e ) => setOauthTokenUrl ( e . target . value ) }
228+ onChange = { ( e ) => {
229+ setOauthTokenUrl ( e . target . value ) ;
230+ } }
212231 />
213232 </ Box >
214233 ) }
0 commit comments