Skip to content

Commit

Permalink
Merge branch 'blank-login'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Jonas committed Nov 25, 2017
2 parents ab5dcad + 34c2871 commit 390d316
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default class Actions extends React.Component {
render() {
return (
<div className="Actions">
<CreateLogin createLogin={this.props.createLogin}/>
<CreateLogin handleCreateLogin={this.props.handleCreateLogin}/>
</div>
)
}
Expand Down
11 changes: 10 additions & 1 deletion src/components/CreateLogin.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,16 @@ export default class CreateLogin extends React.Component {
e.preventDefault()
const username = e.target.elements.username.value.trim()
const password = e.target.elements.password.value.trim()
const success = this.props.createLogin(username, password)

if (!username || !password) {
this.setState(() => ({
createLoginModalErrorMessage: 'Fields cannot be empty!'
}))
return false
}


const success = this.props.handleCreateLogin(username, password)

if (success) {
this.setState(() => ({
Expand Down
4 changes: 2 additions & 2 deletions src/components/LoginManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ export default class LoginManager extends React.Component {
handleDelete={this.handleDeleteLogin}
/>
<Actions
createLogin={this.createLogin}
handleCreateLogin={this.handleCreateLogin}
/>
</div>
)
}

createLogin = (username, password) => {
handleCreateLogin = (username, password) => {
const matchedLogin = this._findLogin({ username, password })

if (matchedLogin) {
Expand Down
7 changes: 7 additions & 0 deletions src/components/Logins.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ export default class Logins extends React.Component {
const newUsername = e.target.elements.newUsername.value.trim()
const newPassword = e.target.elements.newPassword.value.trim()

if (!newUsername || !newPassword) {
this.setState(() => ({
editLoginModalErrorMessage: 'Fields cannot be empty!'
}))
return false;
}

if ((newUsername === this.state.editingLogin.username)
&& newPassword === this.state.editingLogin.password) {
// didn't change at all.
Expand Down

0 comments on commit 390d316

Please sign in to comment.