2019-01-22 00:41:13 -08:00
|
|
|
import React, { Component } from "react";
|
|
|
|
|
2019-01-25 02:19:22 -08:00
|
|
|
import './App.scss';
|
|
|
|
|
2019-01-24 02:56:41 -08:00
|
|
|
const backendUrl = "https://kucinakobackend.ichigo.everydayimshuflin.com";
|
|
|
|
|
|
|
|
function makeRequest(queryString, jsonHandler) {
|
|
|
|
const effectiveUrl = `${backendUrl}/${queryString}`
|
|
|
|
fetch(`${backendUrl}`)
|
|
|
|
.then((resp) => {
|
|
|
|
return resp.json()
|
|
|
|
})
|
|
|
|
.then((json) => {
|
|
|
|
jsonHandler(json);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function testHandler(json) {
|
|
|
|
console.log("JSON");
|
|
|
|
console.log(json);
|
|
|
|
}
|
|
|
|
|
2019-01-22 00:41:13 -08:00
|
|
|
class App extends Component {
|
2019-01-24 02:56:41 -08:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.input = React.createRef();
|
|
|
|
this.handleSubmit = this.handleSubmit.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleSubmit(event) {
|
|
|
|
const value = this.input.current.value;
|
|
|
|
console.log("handling submit with value: ", value);
|
|
|
|
makeRequest("", testHandler);
|
|
|
|
}
|
|
|
|
|
2019-01-22 00:41:13 -08:00
|
|
|
render() {
|
|
|
|
return(
|
2019-01-25 02:19:22 -08:00
|
|
|
<main>
|
|
|
|
<div className='container'>
|
|
|
|
<h1>Kucinako</h1>
|
|
|
|
<div className='textInput'>
|
|
|
|
<input className='textInput' type="text" ref={ this.input } />
|
|
|
|
</div>
|
|
|
|
<br/>
|
|
|
|
<button onClick={ this.handleSubmit }>Saimiar</button>
|
|
|
|
<button onClick={ this.handleSubmit }>English</button>
|
|
|
|
</div>
|
|
|
|
</main>
|
2019-01-22 00:41:13 -08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default App;
|