Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
61 lines (59 sloc) 1.62 KB
<div id="app"></div>
<!-- -->
<script type="text/babel">
class Create extends React.Component {
constructor(props){
super(props)
this.state = {title: '', description: ''}
}
handleChangeTitle(e){
this.setState({title: e.target.value})
}
handleChangeDesc(e){
this.setState({description: e.target.value})
}
handleSubmit(e){
e.preventDefault()
const task = {
title: this.state.title,
content: this.state.description
}
let uri = '/api/tasks_new'
axios.post(uri, task ).then((response) => {
// browserHistory.push('/list')
window.location.href="/tasks"
console.log("success")
})
}
render() {
return (
<div>
<h1>Create a ToDo</h1>
<hr />
<form onSubmit={this.handleSubmit.bind(this)}>
<div className="row">
<div className="col-md-6">
<div className="form-group">
<label>Title:</label>
<input type="text" className="form-control" onChange={this.handleChangeTitle.bind(this)}/>
</div>
</div>
</div>
<div className="row">
<div className="col-md-6">
<div className="form-group">
<label>Description:</label>
<input type="text" className="form-control col-md-6" onChange={this.handleChangeDesc.bind(this)}/>
</div>
</div>
</div><br />
<div className="form-group">
<button className="btn btn-primary">Create</button>
</div>
</form>
</div>
)
}
}
ReactDOM.render(<Create />, document.getElementById('app'));
</script>
You can’t perform that action at this time.