11import React , { useState } from 'react' ;
22import { Container , Paper , Typography , Button , TextField } from '@material-ui/core' ;
33import axios from 'axios' ;
4+ import * as TransferFuncVar from './TransferFuncVar.js' ;
45
56const TransferFunc = ( ) => {
6- const [ text , setText ] = useState ( '' ) ; // State for file content
7- const [ token , setToken ] = useState ( '' ) ; // State for token input
7+ const [ A , setA ] = useState ( TransferFuncVar . A ) ; // State for A
8+ const [ B , setB ] = useState ( TransferFuncVar . B ) ; // State for B
9+ const [ C , setC ] = useState ( TransferFuncVar . C ) ; // State for C
10+ const [ token , setToken ] = useState ( '' ) ; // State for GitHub token
811
912 const uploadFile = async ( ) => {
10- const filePath = `src/component/test .js` ;
13+ const filePath = `src/component/TransferFuncVar .js` ;
1114 const repoOwner = 'iDataVisualizationLab' ;
1215 const repoName = 'TxDOT' ;
1316 const branch = 'main' ;
@@ -37,13 +40,20 @@ const TransferFunc = () => {
3740 const sha = await getFileSHA ( ) ;
3841 console . log ( 'File SHA:' , sha ) ;
3942
40- const content = btoa ( unescape ( encodeURIComponent ( text ) ) ) ; // Convert text to base64
43+ // Prepare the updated content for the file
44+ const updatedContent = `
45+ export const A = ${ A } ;
46+ export const B = ${ B } ;
47+ export const C = ${ C } ;
48+ ` ;
49+
50+ const content = btoa ( unescape ( encodeURIComponent ( updatedContent ) ) ) ; // Convert text to base64
4151
4252 try {
4353 const response = await axios . put (
4454 `https://api.github.com/repos/${ repoOwner } /${ repoName } /contents/${ filePath } ` ,
4555 {
46- message : sha ? 'Update TransferFunc .js file' : 'Create TransferFunc .js file' ,
56+ message : sha ? 'Update TransferFuncVar .js file' : 'Create TransferFuncVar .js file' ,
4757 content : content ,
4858 sha : sha ,
4959 branch : branch ,
@@ -67,20 +77,37 @@ const TransferFunc = () => {
6777 Transfer Function Page
6878 </ Typography >
6979 < Typography variant = "body1" align = "center" >
70- This is the Transfer Function page content .
80+ Update the values of A, B, and C below .
7181 </ Typography >
72-
82+
83+ < TextField
84+ label = "Value for A"
85+ type = "number"
86+ variant = "outlined"
87+ fullWidth
88+ margin = "normal"
89+ value = { A }
90+ onChange = { ( e ) => setA ( e . target . value ) }
91+ />
7392 < TextField
74- label = "File Content"
75- multiline
76- rows = { 4 }
93+ label = "Value for B"
94+ type = "number"
7795 variant = "outlined"
7896 fullWidth
7997 margin = "normal"
80- value = { text }
81- onChange = { ( e ) => setText ( e . target . value ) }
98+ value = { B }
99+ onChange = { ( e ) => setB ( e . target . value ) }
82100 />
83-
101+ < TextField
102+ label = "Value for C"
103+ type = "number"
104+ variant = "outlined"
105+ fullWidth
106+ margin = "normal"
107+ value = { C }
108+ onChange = { ( e ) => setC ( e . target . value ) }
109+ />
110+
84111 < TextField
85112 label = "GitHub Token"
86113 type = "password" // Hides token input for security
0 commit comments