Guest User

Untitled

a guest
Mar 21st, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. class LoginForm extends Component {
  2. constructor(props) {
  3. super(props)
  4. this.state = {
  5. details: {
  6. email: '',
  7. password: '',
  8. },
  9. hasError: false,
  10. errorText: 'Errors: n',
  11. }
  12. }
  13.  
  14. render() {
  15. let { hasError, errorText } = this.state
  16. const { LogUserIn } = this.props
  17.  
  18. const onTapLogin = e => {
  19.  
  20. // broken?
  21. if (hasError) {
  22. this.setState({
  23. hasError: false,
  24. errorText: 'Errors: n',
  25. })
  26. }
  27.  
  28. if (!check.emailValid(e.email)){
  29. this.setState({
  30. hasError: true,
  31. errorText: errorText += "n - Email address is invalid. "
  32. })
  33. }
  34.  
  35. if (!check.passwordValid(e.password)){
  36. this.setState({
  37. hasError: true,
  38. errorText: errorText += "n- Password is invalid. "
  39. })
  40. }
  41.  
  42. if (!hasError){
  43. LogUserIn(e)
  44. }
  45. }
  46.  
  47. return (
  48. <div {...cssLoginFormContainer}>
  49. <div {...cssLoginFormHeader}>SIGN IN</div>
  50.  
  51. <div {...(hasError ? cssErrorText : cssErrorText_hide)}>
  52. {errorText}
  53. </div>
  54. ...
  55. // the form.
Add Comment
Please, Sign In to add comment