From 99c4129657d31e4fb73f1722a0291a8ade102898 Mon Sep 17 00:00:00 2001 From: Prabin Shrestha Date: Mon, 4 Oct 2021 17:40:54 +0545 Subject: [PATCH] Some ui logic change --- src/App.js | 223 ++++++++++++--------------------------------------- src/index.js | 15 ++-- 2 files changed, 59 insertions(+), 179 deletions(-) diff --git a/src/App.js b/src/App.js index 1dc0c8f..996135d 100644 --- a/src/App.js +++ b/src/App.js @@ -5,7 +5,7 @@ import "./newcss.css"; import axios from "axios"; import AceEditor from "react-ace"; import ReactLoading from "react-loading"; -import 'bootstrap/dist/css/bootstrap.min.css'; +import "bootstrap/dist/css/bootstrap.min.css"; import "ace-builds/src-noconflict/mode-c_cpp"; import "ace-builds/src-noconflict/mode-java"; @@ -13,12 +13,14 @@ import "ace-builds/src-noconflict/theme-terminal"; import "ace-builds/src-noconflict/theme-monokai"; import "ace-builds/src-noconflict/theme-twilight"; import "ace-builds/src-noconflict/theme-github"; -import Select from "react-select" +import Select from "react-select"; // options and values for the select -const options = [{ value: 'c', label: 'C' }, -{ value: 'cpp', label: 'CPP' }, { value: 'java', label: 'JAVA' } -] +const options = [ + { value: "c", label: "C" }, + { value: "cpp", label: "CPP" }, + { value: "java", label: "JAVA" }, +]; class App extends Component { constructor() { @@ -27,7 +29,7 @@ class App extends Component { code: "", input: "", output: "", - submit: false + submit: false, }; } @@ -37,29 +39,29 @@ class App extends Component { // }; //-------------------------------------------------------// //es6 function to handle change in code and it avoid using bind in the default constructor - handleCodeChange = newValue => { - this.setState({ code: newValue }); + handleCodeChange = (val) => { + this.setState({ code: val }); }; //es6 function to handle change in input - handleInputChange = event => { + handleInputChange = (event) => { this.setState({ input: event.target.value }); }; //es6 function to handle change on submit which is asynchronous using async await //https://entercoding-api-gces.herokuapp.com/compiler/java - handleSubmit = async event => { + handleSubmit = async (event) => { this.setState({ submit: true }); // console.log(this.state.code); //event.preventDefault(); await axios - .post("https://entercoding-api-gces.herokuapp.com/compiler/java", { + .post("https://entercoding-api-gces.herokuapp.com/compiler/nodejs", { code: this.state.code, - input: this.state.input + input: this.state.input, }) - .then(response => { + .then((response) => { console.log(response); - this.setState({ submit: false }); + this.setState({ submit: true }); this.setState({ output: response.data.output + @@ -67,82 +69,71 @@ class App extends Component { "\nCpu Memory : " + response.data.memory + "\nExecution Time : " + - response.data.cpuTime + response.data.cpuTime, }); }) - .catch(error => { + .catch((error) => { console.log(error); }); }; render() { const customStyles = { - control: base => ({ + control: (base) => ({ ...base, - minHeight: 20 + minHeight: 20, }), - dropdownIndicator: base => ({ + dropdownIndicator: (base) => ({ ...base, - padding: 1 + padding: 1, }), - input: base => ({ + input: (base) => ({ ...base, margin: 0, - padding: 0 - }) + padding: 0, + }), }; - return( - -
- -
- -
-
- - -
- ({ ...theme, - borderRadius: 7 // to make same border as the run button + borderRadius: 7, // to make same border as the run button })} - /> -
- -
- -
- - {/* editor */} -
- { this.handleSubmit(); - } - } + }, + }, ]} />
- - - -
+
-
- -
- -
- -
- +
+
+
+
-
- +
- +
- - - ) + ); } - - - // return ( - //
- //
- //
- //
- - //
- // {/*
*/} - //
- - //