Skip to content

Instantly share code, notes, and snippets.

@antyakushev
Created November 7, 2016 12:00
Show Gist options
  • Save antyakushev/0dfe8c9a19c1df228c4a0cd203ec3b95 to your computer and use it in GitHub Desktop.
Save antyakushev/0dfe8c9a19c1df228c4a0cd203ec3b95 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react'
import autobind from 'autobind-decorator'
import { reduxForm } from 'redux-form'
import { login, forgot } from 'actions/user'
import styles from './styles'
@reduxForm(
{
form: 'login-form',
fields: ['email', 'password'],
validate: ({ email, password }) => { // eslint-disable-line
const errors = {}
if (!email) { errors.email = 'Field Required *' }
if (!password) { errors.password = 'Field Required *' }
return errors
},
},
null,
{
login: login.init,
forgot: forgot.init,
},
)
class Login extends Component {
@autobind
loginFlow(values) {
return new Promise((resolve, reject) => {
this.props.login({ ...values, resolve, reject })
})
}
render() {
const {
handleSubmit,
submitting,
fields: { email, password },
error,
} = this.props
return (
<form className={styles.loginForm} onSubmit={handleSubmit(this.loginFlow)}>
<input {...email} type="email" value={email.value} placeholder="email" />
{
email.touched &&
<div className={styles.error}>{email.error}</div>
}
<input {...password} type="password" value={password.value} placeholder="password" />
{
password.touched &&
<div className={styles.error}>{password.error}</div>
}
{
error &&
<div className={styles.error}>{error.error}</div>
}
<a className={styles.forgot} onClick={this.props.forgot}>
Forgot password
</a>
<button className={styles.login} disabled={submitting}>
{ submitting ? '+' : '-' } Log in
</button>
</form>
)
}
}
export default Login
@uthpala091998
Copy link

js

@uthpala091998
Copy link

can u help me to create new mesh using javascript

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment