vit9 5 tahun lalu
induk
melakukan
d6345cf63b
2 mengubah file dengan 25 tambahan dan 15 penghapusan
  1. 5 4
      src/components/Auth/authorisation.js
  2. 20 11
      src/components/Auth/registration.js

+ 5 - 4
src/components/Auth/authorisation.js

@@ -1,7 +1,8 @@
 import React from "react";
 import { reduxForm, Field } from "redux-form";
-import  authValidate  from "../../utils/validate";
 import Authbuttons from './authButtons'
+import {authValidate} from "../../utils/authValidate";
+import {authRenderField} from "../../common/authRenderField"
 
 const Form = props => {
   const { handleSubmit, getUsersData } = props
@@ -15,7 +16,7 @@ const Form = props => {
           <div>
             <Field
               name="email"
-              component="input"
+              component={authRenderField}
               type="Емейл" 
               placeholder="email@example.com"
 
@@ -24,12 +25,12 @@ const Form = props => {
           <div>  
             <Field
               name="password"
-              component="input" 
+              component={authRenderField}
               type="password" 
               placeholder ="Пароль"  
             />
           </div>
-          <button className="auth__submit-button">Отправить</button>
+          <button className="auth__submit-button">Войти</button>
         </form>
       </div>
     );

+ 20 - 11
src/components/Auth/registration.js

@@ -1,8 +1,13 @@
 import React from 'react'
 import { Field, reduxForm } from 'redux-form'
 import Authbuttons from './authButtons'
+import {regValidate} from '../../utils/regValidate'
+import {regRenderField} from '../../common/regRenderField'
+
+
 
 const RegistrForm = props => {
+
   const { handleSubmit, pristine, reset, postUsersData } = props
   const submit = (values) =>{
     values.avatar = "https://site.com"
@@ -14,64 +19,68 @@ const RegistrForm = props => {
   return (
     <div>
       <Authbuttons />
-      <form onSubmit={handleSubmit(submit)}>
+      <form onSubmit={handleSubmit(submit)} className="form">
         <div>
           <div>
             <Field
               name="login"
-              component="input"
+              component={regRenderField}
               type="text"
               placeholder="Логин"
+              className="input"
             />
           </div>
 
           <div>
             <Field
               name="password"
-              component="input"
+              component={regRenderField}
               type="password"
               placeholder="Пароль"
+              className="input"
               />
           </div>
 
           <div>
             <Field
               name="name"
-              component="input"
+              component={regRenderField}
               type="text"
               placeholder="Имя"
+              className="input"
             />
           </div>
           <div>
             <Field
               name="phone"
-              component="input"
+              component={regRenderField}
               type="text"
               placeholder="+380XXXXXXXX"
+              className="input"
             />
           </div>
           <div>
             <Field
               name="email"
-              component="input"
+              component={regRenderField}
               type="email"
               placeholder="email@example.com"
+              className="input"
             />
           </div>
         </div>
         <div>
-          <button type="submit" disabled={pristine} >
+          <button type="submit" disabled={pristine} className="button">
             Отправить
           </button>
-          <button type="button" disabled={pristine} onClick={reset}>
+          <button type="button" disabled={pristine} onClick={reset} className="button">
             Очистить поля
           </button>
         </div>
         </form>
       </div>
+
   )
 }
 
-export default reduxForm({
-  form: 'registrForm'
-})(RegistrForm)
+export default reduxForm({ form: 'registrForm', validate: regValidate})(RegistrForm)