@@ -143,9 +143,6 @@ class TransferFunc extends Component {
143143 } ) ;
144144 const shaTransferFuncVar = await getFileSHA ( filePath ) ;
145145 const shaPackageJson = await getFileSHA ( 'package.json' ) ;
146- this . setState ( {
147- loading : false
148- } ) ; // Reset loading after the request is done
149146 const updatedContent = `
150147 export const A = ${ A } ;
151148 export const B = ${ B } ;
@@ -192,10 +189,16 @@ class TransferFunc extends Component {
192189
193190 // Show success alert
194191 alert ( 'File uploaded successfully!' ) ;
192+ this . setState ( {
193+ loading : false
194+ } ) ;
195195 this . props . toMenu ( ) ;
196196 } catch ( error ) {
197197 console . error ( 'Error uploading file' , error ) ;
198198
199+ this . setState ( {
200+ loading : false
201+ } ) ;
199202 // Check if the error is due to an invalid token (401 Unauthorized)
200203 if ( error . response && error . response . status === 401 ) {
201204 alert ( 'Error: Invalid GitHub token. Please check your token and try again.' ) ;
@@ -231,7 +234,7 @@ class TransferFunc extends Component {
231234 } ;
232235
233236 render ( ) {
234- const { A, B, C, token, version, errorA, errorB, errorC, errorToken, errorVersion, loading } = this . state ;
237+ const { A, B, C, token, version, errorA, errorB, errorC, errorToken, errorVersion, loading} = this . state ;
235238
236239 // Generate FC values and PO values
237240 const FCValues = Array . from ( { length : 1000 } , ( _ , i ) => Math . pow ( 10 , - 3 + ( i * 6 ) / 999 ) ) ; // From 1e-3 to 1e3
@@ -271,7 +274,7 @@ class TransferFunc extends Component {
271274 { /* Form Section */ }
272275 < Grid item xs = { 12 } sm = { 6 } >
273276 < Typography variant = "body1" align = "center" gutterBottom style = { { color : '#1976d2' , fontSize : '2rem' } } >
274- < MathJax style = { { fontSize : '2rem' , textAlign : 'center' } } >
277+ < MathJax key = { ` ${ A } - ${ B } - ${ C } ` } style = { { fontSize : '2rem' , textAlign : 'center' } } >
275278 { `\\( New \\ PO_{Texas} = \\frac{${ A } }{1 + ${ B } \\cdot (FC)^{${ C } }} \\)` }
276279 </ MathJax >
277280 </ Typography >
@@ -288,21 +291,45 @@ class TransferFunc extends Component {
288291 { label : 'GitHub Token' , value : token , error : errorToken , type : 'password' , onChange : ( e ) => this . setState ( { token : e . target . value } ) } ,
289292 { label : 'Version' , value : version , error : errorVersion , type : 'text' , onChange : ( e ) => this . setState ( { version : e . target . value } ) }
290293 ] . map ( ( { label, value, error, type = 'number' , onChange } , index ) => (
291- < TextField
292- key = { index }
293- label = { label }
294- type = { type }
295- variant = "outlined"
296- fullWidth
297- margin = "normal"
298- value = { value }
299- onChange = { onChange }
300- error = { error }
301- helperText = { error ? `Please enter a valid ${ label . toLowerCase ( ) } .` : '' }
302- style = { { fontSize : '1.2rem' , marginBottom : '20px' } }
303- />
294+ < React . Fragment key = { index } >
295+ { label === 'GitHub Token' ? (
296+ < div style = { { display : 'flex' , alignItems : 'center' , marginBottom : '20px' } } >
297+ < TextField
298+ label = { label }
299+ type = { type }
300+ variant = "outlined"
301+ fullWidth
302+ value = { value }
303+ onChange = { onChange }
304+ error = { error }
305+ helperText = { error ? `Please enter a valid ${ label . toLowerCase ( ) } .` : '' }
306+ style = { { marginRight : '10px' } }
307+ />
308+ < Button
309+ color = "primary"
310+ variant = "outlined"
311+ onClick = { this . props . handleHelpClick }
312+ style = { { fontSize : '0.875rem' , padding : '2px 16px' } }
313+ >
314+ What is a Token?
315+ </ Button >
316+ </ div >
317+ ) : (
318+ < TextField
319+ label = { label }
320+ type = { type }
321+ variant = "outlined"
322+ fullWidth
323+ margin = "normal"
324+ value = { value }
325+ onChange = { onChange }
326+ error = { error }
327+ helperText = { error ? `Please enter a valid ${ label . toLowerCase ( ) } .` : '' }
328+ style = { { fontSize : '1.2rem' , marginBottom : '20px' } }
329+ />
330+ ) }
331+ </ React . Fragment >
304332 ) ) }
305-
306333 { /* Buttons */ }
307334 < div style = { { display : 'flex' , justifyContent : 'center' } } >
308335 < Button
0 commit comments