Browse Source

created redirect on the registration page

Tanya Sashyna 5 years ago
parent
commit
c477df24fc

+ 2 - 6
src/components/login-form/LoginForm.js

@@ -14,12 +14,8 @@ let LoginForm = props => {
 
     return (
         <form className="form" onSubmit={handleSubmit(submit)}>
-            <div>
-                <Field name="email" component={customInput} type="email" id="email" label="E-mail"/>
-            </div>
-            <div>
-                <Field name="password" component={customInput} type="password" id="password" label="Password"/>
-            </div>
+            <Field name="email" component={customInput} type="email" id="email" label="E-mail" />
+            <Field name="password" component={customInput} type="password" id="password" label="Password"/>
             <button type="submit" className="btn">Sign in</button>
         </form>
         )

+ 7 - 16
src/components/registration-form/RegistrationForm.js

@@ -9,15 +9,14 @@ let RegistrationForm = props => {
     const { handleSubmit, postCheckInSubmit } = props;
 
     const submit = value => {
-        console.log(value);        
+        //console.log(value);        
         postCheckInSubmit(value);
+        props.history.push('/login');
     };
 
     return (
         <form className="form" onSubmit={handleSubmit(submit)}>
-            <div>
-                <Field name="name" component={customInput} type="text" id="name" label="Full name"/>
-            </div>
+            <Field name="name" component={customInput} type="text" id="name" label="Full name"/>
             <div className="reg-radio">
                 <div className="radio-label">
                     <Field name="sex" component="input" type="radio" id="male" value="male" hidden/>
@@ -29,18 +28,10 @@ let RegistrationForm = props => {
                     <label htmlFor="female">female</label>
                 </div>
             </div>
-            <div>
-                <Field name="phone" component={customInput} type="phone" id="phone" label="Phone"/>
-            </div>
-            <div>
-                <Field name="email" component={customInput} type="email" id="email" label="E-mail"/>
-            </div>
-            <div>
-                <Field name="password" component={customInput} type="password" id="password" label="Password"/>
-            </div>
-            <div>
-                <Field name="confirmPassword" component={customInput} type="password" id="confirmPassword" label="Confirm Password"/>
-            </div>
+            <Field name="phone" component={customInput} type="phone" id="phone" label="Phone"/>
+            <Field name="email" component={customInput} type="email" id="email" label="E-mail"/>
+            <Field name="password" component={customInput} type="password" id="password" label="Password"/>
+            <Field name="confirmPassword" component={customInput} type="password" id="confirmPassword" label="Confirm Password"/>
             
             <button type="submit" className="btn">Check in</button>
         </form>

+ 2 - 2
src/conteiners/registrationPage/RegistrationPage.js

@@ -10,7 +10,7 @@ import RegistrationForm from '../../components/registration-form/RegistrationFor
 
 export class Login extends React.Component {
     render() {
-        const { message } = this.props;
+        const { message, history } = this.props;
 
         return (
             <div className="reg-page">
@@ -18,7 +18,7 @@ export class Login extends React.Component {
                     {
                         message === "User already exist" && <h3>{message}!</h3>
                     }
-                    <RegistrationForm postCheckInSubmit={this.props.postCheckInSubmit}/>
+                    <RegistrationForm history={history} postCheckInSubmit={this.props.postCheckInSubmit}/>
                     <p className="form-quest">You have an account? <Link to="/login">Login now</Link></p>
                 </div>
             </div>