-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
123 link auth to form #167
Open
benlittlenz
wants to merge
7
commits into
dev
Choose a base branch
from
123-link-auth-to-form
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f5b41d2
Made changes to registration
benlittlenz b5efa72
changes
benlittlenz bb6c719
Register form now working
benlittlenz 9d6f633
Merge branch 'dev' into 123-link-auth-to-form
benlittlenz 876ffab
made binding name changes as well as unneeded code
benlittlenz 34c9d1f
merge conflicts
benlittlenz 3d518b6
fixed conflicts in files
benlittlenz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -9,6 +9,9 @@ import { Paper, | |
MenuItem, | ||
InputLabel } from '@material-ui/core' | ||
|
||
import {connect} from 'react-redux' | ||
import {register, registerError} from '../actions/auth' | ||
|
||
class Register extends React.Component { | ||
state = { | ||
name: '', | ||
|
@@ -25,22 +28,30 @@ class Register extends React.Component { | |
}) | ||
} | ||
|
||
handleSubmit (evt) { | ||
this.props.saveItem(this.state) | ||
this.setState(this.state) | ||
evt.preventDefault() | ||
} | ||
registering = () => { | ||
const { name, surname, password } = this.state | ||
|
||
handleChange = event => { | ||
this.setState({ [event.target.name]: event.target.value }); | ||
} | ||
if(!name) { | ||
return this.props.dispatch(registerFailure('Must provide name.')) | ||
} | ||
if(!surname) { | ||
return this.props.dispatch(registerFailure('Must provide surname.')) | ||
} | ||
if(!password) { | ||
return this.props.dispatch(registerFailure('Must provide email.')) | ||
} | ||
|
||
this.props.dispatch(register({name, surname, password})) | ||
|
||
resetForm (evt) { | ||
this.setState({ | ||
item: this.state, | ||
invalid: {} | ||
name: '', | ||
surname: '', | ||
password: '' | ||
}) | ||
evt && evt.preventDefault() | ||
} | ||
|
||
handleChange = event => { | ||
this.setState({ [event.target.name]: event.target.value }); | ||
} | ||
|
||
render () { | ||
|
@@ -57,26 +68,20 @@ class Register extends React.Component { | |
<Paper style={styles.paper} > | ||
<h1>Register</h1> | ||
<form > | ||
<br/> | ||
<br/> | ||
<TextField | ||
variant="outlined" | ||
label="First name" | ||
name='name' | ||
value={this.state.name} | ||
onChange={this.handleChange} | ||
/> | ||
<br/> | ||
<br/> | ||
<TextField | ||
variant="outlined" | ||
label="Last name" | ||
name='surname' | ||
value={this.state.surname} | ||
onChange={this.handleChange} | ||
/> | ||
<br/> | ||
<br/> | ||
<TextField | ||
variant="outlined" | ||
type='password' | ||
|
@@ -86,9 +91,6 @@ class Register extends React.Component { | |
value={this.state.password} | ||
onChange={this.handleChange} | ||
/> | ||
<br/> | ||
<br/> | ||
|
||
<FormControl variant="outlined" style={{minWidth: '200px'}} > | ||
<InputLabel | ||
ref={ref => { | ||
|
@@ -117,9 +119,6 @@ class Register extends React.Component { | |
</Select> | ||
</FormControl> | ||
|
||
<br/> | ||
<br/> | ||
|
||
<FormControl variant="outlined" style={{minWidth: '200px'}} > | ||
<InputLabel | ||
ref={ref => { | ||
|
@@ -147,14 +146,12 @@ class Register extends React.Component { | |
<MenuItem value={'Kowhai2018'}>Kowhai2018</MenuItem> | ||
</Select> | ||
</FormControl> | ||
<br/> | ||
<br/> | ||
<br/> | ||
<button type='submit' className='button-primary' value='Add' onSubmit={this.handleSubmit} | ||
onClick={this.resetForm}>Register</button> | ||
<br/> | ||
<br/> | ||
<br/> | ||
<button | ||
type='submit' | ||
className='button-primary' | ||
value='Add' | ||
onClick={this.registering} | ||
>Register</button> | ||
</form> | ||
</Paper> | ||
</Grid> | ||
|
@@ -164,4 +161,5 @@ class Register extends React.Component { | |
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you want to refactor lines 96-100, you can do it with one line: |
||
|
||
export default Register | ||
const mapStateToProps = ({auth}) => ({auth}) | ||
export default connect(mapStateToProps)(Register) |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need 2 consecutive blank lines? Your linter should complain about this.