Created
February 4, 2019 18:16
-
-
Save felipeorlando/3b70e2a1e2c29d27b04176b97d671d0a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class Login extends Component { | |
state = { | |
email: { | |
value: '', | |
error: false, | |
validate: validateEmail, | |
}, | |
password: { | |
value: '', | |
error: false | |
}, | |
} | |
onEmailChange = (e) => { | |
this.setState({ email: { value: e.target.value } }); | |
} | |
submit = () => { | |
if (!this.validation()) { | |
this.showErrors(); | |
return false; | |
} | |
} | |
render() { | |
const { email, password } = this.state; | |
return ( | |
<form onSubmit={submit} method="POST" action="/ddklkasdksaldmlk/asdaosndkamdo"> | |
<FieldGroup type="email" name="email" label="Email" error={email.error} value={email.value} onChange={onEmailChange} /> | |
<FieldGroup type="password" name="password" label="Senha" error={password.error} value={password.value} onChange={onPasswordChange} /> | |
<Button type="submit">Submeter</Button> | |
</form> | |
); | |
} | |
} | |
const FieldGroup = ({ | |
lined, | |
error, | |
name, | |
value, | |
onChange, | |
label, | |
}) => { | |
if (lined) { | |
return ( | |
<FormGroup error={error}> | |
<Field lined type={type} name={name} value={value} onChange={onChange}></Field> | |
<Label lined for={name}>label</Label> | |
</FormGroup> | |
) | |
} | |
return ( | |
<FormGroup error={error}> | |
<Label for={name}>label</Label> | |
<Field type={type} name={name} value={value} onChange={onChange}></Field> | |
</FormGroup> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment