Login.jsx 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import React from 'react'
  2. import { connect } from 'react-redux'
  3. import LoginLogo from '../component/Login/LoginLogo.jsx'
  4. import LoginLogoImg from '../img/logoTracimWhite.svg'
  5. import { userLogin } from '../action-creator.async.js'
  6. import Card from '../component/common/Card/Card.jsx'
  7. import CardHeader from '../component/common/Card/CardHeader.jsx'
  8. import CardBody from '../component/common/Card/CardBody.jsx'
  9. import InputGroupText from '../component/common/Input/InputGroupText.jsx'
  10. import InputCheckbox from '../component/common/Input/InputCheckbox.jsx'
  11. import Button from '../component/common/Input/Button.jsx'
  12. import LoginBtnForgotPw from '../component/Login/LoginBtnForgotPw.jsx'
  13. class Login extends React.Component {
  14. constructor (props) {
  15. super(props)
  16. this.state = {
  17. inputLogin: '',
  18. inputPassword: '',
  19. inputRememberMe: false
  20. }
  21. }
  22. handleChangeLogin = e => this.setState({inputLogin: e.target.value})
  23. handleChangePassword = e => this.setState({inputPassword: e.target.value})
  24. handleChangeRememberMe = () => this.setState(prev => ({inputRememberMe: !prev.inputRememberMe}))
  25. handleClickSubmit = () => this.props.dispatch(userLogin(this.state.inputLogin, this.state.inputPassword))
  26. render () {
  27. return (
  28. <section className='loginpage'>
  29. <div className='container-fluid'>
  30. <LoginLogo customClass='loginpage__logo' logoSrc={LoginLogoImg} />
  31. <div className='row justify-content-center'>
  32. <div className='col-12 col-sm-11 col-md-8 col-lg-6 col-xl-5'>
  33. <Card customClass='loginpage__connection'>
  34. <CardHeader customClass='connection__header text-center'>{'Connexion'}</CardHeader>
  35. <CardBody formClass='connection__form'>
  36. <InputGroupText
  37. parentClassName='connection__form__groupemail'
  38. customClass='mb-3 mt-4'
  39. icon='fa-envelope-open-o'
  40. type='email'
  41. placeHolder='Adresse Email'
  42. invalidMsg='Email invalide.'
  43. value={this.state.inputLogin}
  44. onChange={this.handleChangeLogin}
  45. />
  46. <InputGroupText
  47. parentClassName='connection__form__groupepw'
  48. customClass=''
  49. icon='fa-lock'
  50. type='password'
  51. placeHolder='Mot de passe'
  52. invalidMsg='Mot de passe invalide.'
  53. value={this.state.inputPassword}
  54. onChange={this.handleChangePassword}
  55. />
  56. <div className='row mt-4 mb-4'>
  57. <div className='col-12 col-sm-6 col-md-6 col-lg-6 col-xl-6'>
  58. <InputCheckbox
  59. parentClassName='connection__form__rememberme'
  60. customClass=''
  61. label='Se souvenir de moi'
  62. checked={this.state.inputRememberMe}
  63. onChange={this.handleChangeRememberMe}
  64. />
  65. </div>
  66. <div className='col-12 col-sm-6 col-md-6 col-lg-6 col-xl-6 text-sm-right'>
  67. <LoginBtnForgotPw
  68. customClass='connection__form__pwforgot'
  69. label='Mot de passe oublié ?'
  70. />
  71. </div>
  72. </div>
  73. <Button
  74. htmlType='button'
  75. bootstrapType='primary'
  76. customClass='connection__form__btnsubmit'
  77. label='Connexion'
  78. onClick={this.handleClickSubmit}
  79. />
  80. </CardBody>
  81. </Card>
  82. </div>
  83. </div>
  84. </div>
  85. </section>
  86. )
  87. }
  88. }
  89. const mapStateToProps = ({ user }) => ({ user })
  90. export default connect(mapStateToProps)(Login)