@@ -5,7 +5,8 @@ import "../components/css/EditorComponent.css"; // Optional for styling
55import "@fortawesome/fontawesome-free/css/all.css" ;
66import { useSnackbar } from "notistack" ;
77
8- const judge0SubmitUrl = process . env . JUDGE0_SUMBISSION_URL || process . env . REACT_APP_RAPID_API_URL ;
8+ const judge0SubmitUrl =
9+ process . env . JUDGE0_SUMBISSION_URL || process . env . REACT_APP_RAPID_API_URL ;
910const rapidApiHost = process . env . REACT_APP_RAPID_API_HOST ;
1011const rapidApiKey = process . env . REACT_APP_RAPID_API_KEY ;
1112
@@ -75,8 +76,7 @@ function EditorComponent() {
7576 async function submitCode ( ) {
7677 const codeToSubmit = editorRef . current . getValue ( ) ;
7778
78- console . log ( " Code to submit " , codeToSubmit ) ;
79- if ( codeToSubmit === "" ) {
79+ if ( codeToSubmit === "" ) {
8080 enqueueSnackbar ( "Please enter valid code" , { variant : "error" } ) ;
8181 return ;
8282 }
@@ -85,7 +85,7 @@ function EditorComponent() {
8585 method : "POST" ,
8686 headers : {
8787 "Content-Type" : "application/json" ,
88- "X-RapidAPI-Key" : rapidApiKey ,
88+ "X-RapidAPI-Key" : rapidApiKey ,
8989 "X-RapidAPI-Host" : rapidApiHost ,
9090 } ,
9191 body : JSON . stringify ( {
@@ -97,51 +97,47 @@ function EditorComponent() {
9797 } ) ;
9898
9999 if ( ! response . ok ) {
100- enqueueSnackbar ( `Failed to create submission. Status code: ${ response . status } ` , { variant : "error" } ) ;
101- return
100+ enqueueSnackbar (
101+ `Failed to create submission. Status code: ${ response . status } ` ,
102+ { variant : "error" }
103+ ) ;
104+ return ;
102105 }
103106
104107 const data = await response . json ( ) ;
105108 const submissionId = data [ "token" ] ;
106- console . log ( `Submission created successfully. ID: ${ submissionId } ` ) ;
107109
108110 setTimeout ( ( ) => {
109- fetch ( `${ judge0SubmitUrl } /${ submissionId } ` ,
110- {
111- method : "GET" ,
112- headers :{
113- "X-RapidAPI-Key" : rapidApiKey ,
114- "X-RapidAPI-Host" : rapidApiHost ,
115- }
116- }
117- )
111+ fetch ( `${ judge0SubmitUrl } /${ submissionId } ` , {
112+ method : "GET" ,
113+ headers : {
114+ "X-RapidAPI-Key" : rapidApiKey ,
115+ "X-RapidAPI-Host" : rapidApiHost ,
116+ } ,
117+ } )
118118 . then ( ( response ) => response . json ( ) )
119119 . then ( ( data ) => {
120- console . log ( " DATA " , data ) ;
121- console . log ( "Output:" , data . stdout ) ;
122120 setOutput ( data . stdout ) ;
123121 } )
124122 . catch ( ( error ) => {
125- console . error ( "Error retrieving output:" , error . message ) ;
126- enqueueSnackbar ( "Error retrieving output: " + error . message , { variant : "error" } ) ;
123+ enqueueSnackbar ( "Error retrieving output: " + error . message , {
124+ variant : "error" ,
125+ } ) ;
127126 } ) ;
128127 } , 2000 ) ; // Delay added to give Judge0 some time to process the submission
129128 } catch ( error ) {
130- console . error ( "Error:" , error . message ) ;
131129 enqueueSnackbar ( "Error: " + error . message , { variant : "error" } ) ;
132130 }
133131 }
134132
135133 function handleLanguageChange ( e ) {
136- console . log ( "click, " , e . target . value ) ;
137134 setCurrentLanguage ( e . target . value ) ;
138135 setOutput ( "" ) ;
139136 setCode ( null ) ;
140137 }
141138
142139 return (
143140 < div className = "editor-container" style = { styles . container } >
144-
145141 { /* Language toggle button (top right corner) */ }
146142 < div style = { styles . flexBetween } >
147143 { /* Current Language Logo */ }
@@ -165,7 +161,7 @@ function EditorComponent() {
165161 { LANGUAGES . map ( ( language , index ) => (
166162 < option
167163 key = { index }
168- style = { { padding : "0.2em 0.5em" } }
164+ style = { { padding : "0.2em 0.5em" } }
169165 value = { language . DEFAULT_LANGUAGE }
170166 >
171167 { language . NAME }
0 commit comments