11import React , { Component } from 'react' ;
2- import { reduxForm , Field , propTypes , fieldPropTypes } from 'redux-form' ;
2+ import { reduxForm , Field , propTypes } from 'redux-form' ;
3+ import { InputField } from 'react-semantic-redux-form' ;
4+ import { Form , Message } from 'semantic-ui-react' ;
35import registerValidation from './registerValidation' ;
46
5- const Input = ( {
6- input, label, type, meta : { touched, error }
7- } ) => (
8- < div className = { `form-group ${ error && touched ? 'has-error' : '' } ` } >
9- < label htmlFor = { input . name } className = "col-sm-2" >
10- { label }
11- </ label >
12- < div className = "col-sm-10" >
13- < input { ...input } type = { type } className = "form-control" />
14- { error && touched && < span className = "glyphicon glyphicon-remove form-control-feedback" /> }
15- { error &&
16- touched && (
17- < div className = "text-danger" >
18- < strong > { error } </ strong >
19- </ div >
20- ) }
21- </ div >
22- </ div >
23- ) ;
24-
25- Input . propTypes = fieldPropTypes ;
26-
277@reduxForm ( {
288 form : 'register' ,
299 validate : registerValidation
@@ -37,19 +17,17 @@ export default class RegisterForm extends Component {
3717 const { handleSubmit, error } = this . props ;
3818
3919 return (
40- < form className = "form-horizontal" onSubmit = { handleSubmit } >
41- < Field name = "email" type = "text" component = { Input } label = "Email" />
42- < Field name = "password" type = "password" component = { Input } label = "Password" />
43- < Field name = "password_confirmation" type = "password" component = { Input } label = "Password confirmation" />
20+ < Form onSubmit = { handleSubmit } >
21+ < Field name = "email" type = "text" component = { InputField } label = "Email" />
22+ < Field name = "password" type = "password" component = { InputField } label = "Password" />
23+ < Field name = "password_confirmation" type = "password" component = { InputField } label = "Password confirmation" />
4424 { error && (
45- < p className = "text-danger" >
46- < strong > { error } </ strong >
47- </ p >
25+ < Message negative >
26+ < p > { error } </ p >
27+ </ Message >
4828 ) }
49- < button className = "btn btn-success" type = "submit" >
50- < i className = "fa fa-sign-in" /> Register
51- </ button >
52- </ form >
29+ < Form . Button > Register</ Form . Button >
30+ </ Form >
5331 ) ;
5432 }
5533}
0 commit comments