Browse Source

added handler for all input in login page + added precision to proptype check for Card

Skylsmoi 7 years ago
parent
commit
258dfc8f1e

+ 5 - 3
src/component/common/Card/Card.jsx View File

22
   // ),
22
   // ),
23
 
23
 
24
   // from http://www.mattzabriskie.com/blog/react-validating-children
24
   // from http://www.mattzabriskie.com/blog/react-validating-children
25
-  children: PropTypes.arrayOf((propValue, key, componentName /* , location, propFullName */) => {
25
+  children: PropTypes.arrayOf((children, key, componentName /* , location, propFullName */) => {
26
     if (
26
     if (
27
-      key >= 3 ||
28
-      propValue.some(p => p.type !== CardHeader && p.type !== CardBody)
27
+      children.length > 2 ||
28
+      children[0].type !== CardHeader ||
29
+      children[1].type !== CardBody
30
+      // children.some(p => p.type !== CardHeader && p.type !== CardBody)
29
     ) {
31
     ) {
30
       return new Error(`PropType Error: childrens of ${componentName} must be: 1 CardHeader and 1 CardBody.`)
32
       return new Error(`PropType Error: childrens of ${componentName} must be: 1 CardHeader and 1 CardBody.`)
31
     }
33
     }

+ 8 - 1
src/component/common/Input/InputCheckbox.jsx View File

5
 const InputGroupText = props => {
5
 const InputGroupText = props => {
6
   return (
6
   return (
7
     <label className={classnames(`${props.parentClassName}`, props.customClass, 'custom-control custom-checkbox')}>
7
     <label className={classnames(`${props.parentClassName}`, props.customClass, 'custom-control custom-checkbox')}>
8
-      <input type='checkbox' className='custom-control-input' />
8
+      <input
9
+        type='checkbox'
10
+        className='custom-control-input'
11
+        checked={props.checked}
12
+        onChange={props.onChange}
13
+      />
9
       <span className={classnames(`${props.parentClassName}__checkbox`, 'custom-control-indicator')} />
14
       <span className={classnames(`${props.parentClassName}__checkbox`, 'custom-control-indicator')} />
10
       <span className={classnames(`${props.parentClassName}__label`, 'custom-control-description')}>
15
       <span className={classnames(`${props.parentClassName}__label`, 'custom-control-description')}>
11
         {props.label}
16
         {props.label}
18
 
23
 
19
 InputGroupText.PropTypes = {
24
 InputGroupText.PropTypes = {
20
   parentClassName: PropTypes.string.isRequired,
25
   parentClassName: PropTypes.string.isRequired,
26
+  checked: PropTypes.bool.isRequired,
27
+  onChange: PropTypes.func.isRequired,
21
   customClass: PropTypes.string,
28
   customClass: PropTypes.string,
22
   label: PropTypes.string
29
   label: PropTypes.string
23
 }
30
 }

+ 5 - 1
src/container/Login.jsx View File

16
     super(props)
16
     super(props)
17
     this.state = {
17
     this.state = {
18
       inputLogin: '',
18
       inputLogin: '',
19
-      inputPassword: ''
19
+      inputPassword: '',
20
+      inputRememberMe: false
20
     }
21
     }
21
   }
22
   }
22
 
23
 
23
   handleChangeLogin = e => this.setState({inputLogin: e.target.value})
24
   handleChangeLogin = e => this.setState({inputLogin: e.target.value})
24
   handleChangePassword = e => this.setState({inputPassword: e.target.value})
25
   handleChangePassword = e => this.setState({inputPassword: e.target.value})
26
+  handleChangeRememberMe = () => this.setState(prev => ({inputRememberMe: !prev.inputRememberMe}))
25
 
27
 
26
   handleClickSubmit = () => this.props.dispatch(userLogin(this.state.inputLogin, this.state.inputPassword))
28
   handleClickSubmit = () => this.props.dispatch(userLogin(this.state.inputLogin, this.state.inputPassword))
27
 
29
 
67
                         parentClassName='connection__form__rememberme'
69
                         parentClassName='connection__form__rememberme'
68
                         customClass=''
70
                         customClass=''
69
                         label='Se souvenir de moi'
71
                         label='Se souvenir de moi'
72
+                        checked={this.state.inputRememberMe}
73
+                        onChange={this.handleChangeRememberMe}
70
                       />
74
                       />
71
                     </div>
75
                     </div>
72
 
76