@@ -73,6 +73,7 @@ interface CodeSpaceMap {
7373 workspaceID : string ;
7474 codeSpaceURL : string ;
7575 userPubkey : string ;
76+ username ?: string ;
7677 githubPat ?: string ;
7778 baseBranch ?: string ;
7879}
@@ -92,6 +93,7 @@ const ManageCodeSpaceModal: React.FC<CodeSpaceProps> = ({
9293} ) => {
9394 const { main, ui } = useStores ( ) ;
9495 const [ codeSpace , setCodeSpace ] = useState < CodeSpaceMap | null > ( null ) ;
96+ const [ username , setUsername ] = useState ( '' ) ;
9597 const [ githubPat , setGithubPat ] = useState ( '' ) ;
9698 const [ baseBranch , setBaseBranch ] = useState ( '' ) ;
9799 const [ urlError , setUrlError ] = useState ( false ) ;
@@ -127,6 +129,7 @@ const ManageCodeSpaceModal: React.FC<CodeSpaceProps> = ({
127129 if ( response && response . id ) {
128130 // Check if response is valid and has an ID
129131 setCodeSpace ( response ) ;
132+ setUsername ( response . username || '' ) ; // Initialize Username state
130133 setGithubPat ( response . githubPat || '' ) ; // Initialize PAT state
131134 setBaseBranch ( response . baseBranch || '' ) ; // Initialize Base Branch state
132135 setUrlError ( ! isValidCodeSpaceInput ( response . codeSpaceURL ) ) ; // Also validate fetched input
@@ -185,6 +188,10 @@ const ManageCodeSpaceModal: React.FC<CodeSpaceProps> = ({
185188 setUrlError ( ! isValidCodeSpaceInput ( newUrl ) ) ;
186189 } ;
187190
191+ const handleUsernameChange = ( e : React . ChangeEvent < HTMLInputElement > ) => {
192+ setUsername ( e . target . value ) ;
193+ } ;
194+
188195 const handlePatChange = ( e : React . ChangeEvent < HTMLInputElement > ) => {
189196 setGithubPat ( e . target . value ) ;
190197 } ;
@@ -198,9 +205,10 @@ const ManageCodeSpaceModal: React.FC<CodeSpaceProps> = ({
198205
199206 setIsLoading ( true ) ;
200207 try {
201- // Prepare the payload including the githubPat and baseBranch
208+ // Prepare the payload including the username, githubPat and baseBranch
202209 const payload = {
203210 ...codeSpace ,
211+ username : username , // Add the Username from state
204212 githubPat : githubPat , // Add the PAT from state
205213 baseBranch : baseBranch , // Add the Base Branch from state
206214 workspaceID : workspaceUUID , // Ensure workspaceID is always set
@@ -215,12 +223,14 @@ const ManageCodeSpaceModal: React.FC<CodeSpaceProps> = ({
215223 // Create new code space
216224 // Remove id, createdAt, updatedAt before creating
217225 const createPayload : Omit < CodeSpaceMap , 'id' | 'createdAt' | 'updatedAt' > & {
226+ username ?: string ;
218227 githubPat ?: string ;
219228 baseBranch ?: string ;
220229 } = {
221230 workspaceID : workspaceUUID ,
222231 codeSpaceURL : codeSpace . codeSpaceURL ,
223232 userPubkey : ui . meInfo ?. pubkey || '' ,
233+ username : username ,
224234 githubPat : githubPat ,
225235 baseBranch : baseBranch
226236 } ;
@@ -264,6 +274,15 @@ const ManageCodeSpaceModal: React.FC<CodeSpaceProps> = ({
264274 style = { { borderColor : urlError ? '#FF8F80' : '' } }
265275 />
266276 </ Wrapper >
277+ < Wrapper >
278+ < Label > Username:</ Label >
279+ < TextInput
280+ type = "text"
281+ placeholder = "Enter Username"
282+ value = { username }
283+ onChange = { handleUsernameChange }
284+ />
285+ </ Wrapper >
267286 < Wrapper >
268287 < Label > GitHub PAT:</ Label >
269288 < TextInput
0 commit comments