Skip to content

Commit

Permalink
Add workout logger form
Browse files Browse the repository at this point in the history
  • Loading branch information
papajo committed Apr 17, 2016
1 parent 34fa53f commit 58b83dd
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
6 changes: 4 additions & 2 deletions package.json
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
"vinyl-source-stream": "*",
"object-assign": "*"
},
"dependencies":{
"dependencies": {
"node-uuid": "^1.4.7",
"react": "^0.14.7",
"react-dom": "^0.14.7"
"react-dom": "^0.14.7",
"uuid": "^2.0.2"
}
}
29 changes: 27 additions & 2 deletions src/js/components/AddForm.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,40 @@
var React = require('react');
var AppActions = require('../actions/AppActions');
var AppStore = require('../stores/AppStore');
var uuid = require('node-uuid');

var AddForm = React.createClass({
render: function(){
return(
<div>
FORM
<form onSubmit={this.onSubmit} className="form-group">
<select className="form-control" ref="type">
<option value="Jogging">Jogging</option>
<option value="Weight Lifting">Weight Lifting</option>
<option value="Elliptical">Elliptical</option>
<option value="Yoga">Yoga</option>
<option value="Other">Other</option>
</select>
<div className="form-group">
<input type="text" className="form-control" ref="minutes" placeholder="Minutes" />
</div>
<div className="form-group">
<input type="text" className="form-control" ref="miles" placeholder="Miles (Optional)" />
</div>
<button type="submit" className="btn btn-success btn-block">Log Workout</button>
</form>
</div>
);
},
onSubmit: function(e) {
e.preventDefault();
var workout = {
id: uuid.v4(),
minutes: this.refs.minutes.value.trim(),
miles: this.refs.miles.value.trim(),
date: new Date()
}
console.log(workout);
}
});

module.exports = AddForm;
1 change: 1 addition & 0 deletions src/js/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var React = require('react');
var AppActions = require('../actions/AppActions');
var AppStore = require('../stores/AppStore');
var AddForm = require('./AddForm.js');

function getAppState(){
return {
showForm: AppStore.getShowForm()
Expand Down

0 comments on commit 58b83dd

Please sign in to comment.