-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Daniella Baxter
committed
Jan 29, 2017
1 parent
7fde9c6
commit 47bd046
Showing
10 changed files
with
191 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from 'react'; | ||
import axios from 'axios'; | ||
|
||
class CreateAccount extends React.Component{ | ||
render() { | ||
return( | ||
<div> | ||
<form onSubmit={(event) => this.props.handleSubmit(event)}> | ||
|
||
<div className="form-group"> | ||
<label>Name</label> | ||
<input type="text" | ||
value={this.props.user.name} | ||
name="name" | ||
onChange={(event) => this.props.handleChange(event)} | ||
className="form-control"/> | ||
</div> | ||
|
||
<div className="form-group"> | ||
<label>Email</label> | ||
<input | ||
name="email" | ||
type="text" | ||
value={this.props.user.email} | ||
onChange={(event) => this.props.handleChange(event)} | ||
className="form-control" /> | ||
</div> | ||
|
||
<div className="form-group"> | ||
<label>Password</label> | ||
<input | ||
type="text" | ||
className="form-control" | ||
name="password" | ||
value={this.props.user.password} | ||
onChange={(event) => this.props.handleChange(event)} | ||
/> | ||
</div> | ||
|
||
<button className="btn btn-primary" type="submit">SUBMIT</button> | ||
<button className="btn btn-reset" type="reset">RESET</button> | ||
</form> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default CreateAccount; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import React, { Component } from 'react'; | ||
import { browserHistory } from 'react-router'; | ||
import { connect } from 'react-redux'; | ||
import CreateAccount from '../components/CreateAccount.jsx'; | ||
import axios from 'axios'; | ||
const mapStateToProps = state => { | ||
return {}; | ||
}; | ||
|
||
const mapDispatchToProps = (dispatch) => { | ||
return {}; | ||
}; | ||
|
||
export default connect( | ||
mapStateToProps, | ||
mapDispatchToProps | ||
)( | ||
class extends React.Component{ | ||
constructor(){ | ||
super(); | ||
this.state={ | ||
user:{ | ||
name:'', | ||
email:'', | ||
password:'' | ||
} | ||
} | ||
this.handleSubmit=this.handleSubmit.bind(this); | ||
this.handleChange=this.handleChange.bind(this); | ||
} | ||
|
||
componentDidMount(){ | ||
// let temp=this.state.newProduct; | ||
// temp.genre=this.props.genresList.genresList[0]; | ||
// temp.location=this.props.locationList.locationList[0]; | ||
// this.setState({ | ||
// newProduct:temp | ||
// }) | ||
} | ||
|
||
handleSubmit(e) { | ||
e.preventDefault(); | ||
console.log(this.state); | ||
axios.post('/api/users', this.state.user) | ||
.then((response) => { | ||
browserHistory.push("/"); | ||
}); | ||
} | ||
|
||
handleChange(e){ | ||
let temp=this.state.user; | ||
if (e.target.name==="name") { | ||
temp.name=e.target.value; | ||
this.setState({ | ||
user: temp | ||
}) | ||
} | ||
|
||
if (e.target.name==="email") { | ||
temp.email=e.target.value; | ||
this.setState({ | ||
user: temp | ||
}) | ||
} | ||
|
||
if (e.target.name==="password") { | ||
temp.password=e.target.value; | ||
this.setState({ | ||
user: temp | ||
}) | ||
} | ||
} | ||
|
||
render(){ | ||
return( | ||
<CreateAccount | ||
{...this.state} | ||
{...this.props} | ||
handleSubmit={this.handleSubmit} | ||
handleChange={this.handleChange} | ||
/> | ||
); | ||
} | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
body { | ||
padding-top: 70px; | ||
} | ||
|
||
.btn-primary{ | ||
margin:5px | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters