2 Commit-ok 7b493623fe ... ee935f95e4

Szerző SHA1 Üzenet Dátum
  vit9 ee935f95e4 all 5 éve
  vit9 1632b2cf17 l 5 éve

+ 5 - 0
src/actions/usersAuthActions.js

@@ -2,6 +2,11 @@ import * as types from "../constants/actionTypes";
 
 const axios = require("axios");
 
+export const closeModal = payload => ({
+    type: types.CLOSE_MODAL_WINDOW,
+    payload
+})
+
 const userAuthRequest = payload => ({
     type: types.USER_AUTH_REQUEST,
     payload

+ 5 - 0
src/actions/usersRegistrActions.js

@@ -2,6 +2,11 @@ import * as types from "../constants/actionTypes";
 
 const axios = require("axios");
 
+export const closeModal = payload => ({
+    type: types.CLOSE_MODAL_WINDOW,
+    payload
+})
+
 const userRegRequest = payload => ({
     type: types.USER_REG_REQUEST,
     payload

+ 1 - 1
src/common/authRenderField.js

@@ -2,7 +2,7 @@ import React from "react";
 
 export const authRenderField = ({input, meta: {touched, error}, label, type, placeholder }) => (
     <div className={touched && error ? "form__input-box":"error"}> 
-        {console.log(input.value)} 
+        {console.log(error)} 
         <label className="form__input-label" htmlFor="origin">
             {label}
             <input  className="input" type = {type} placeholder = {placeholder} {...input} />

+ 1 - 1
src/components/AllStaffs/FullInfoAboutStaff.js

@@ -19,7 +19,7 @@ class FullInfoAboutStaff extends Component {
         let str;
 
         str = InfoStaff.map(el => {
-            console.log(el.img)
+            console.log(el.state)
 
             if (el.state) {
                 let str1 = el.img.substr(29)

+ 0 - 5
src/components/AllStaffs/index.js

@@ -9,11 +9,7 @@ class AllStaffs extends Component {
     render() {
         const { inputStaffs, isFetching, isAdmin, getUser } = this.props
         let data;
-
-
         if (isFetching === true) {
-
-
             data = <div className="loader">
                 <Loader type="Triangle"
                     color="#FD7F71"
@@ -31,7 +27,6 @@ class AllStaffs extends Component {
                                 <h4>{el.title}</h4>
                                 <h4>Цена: {el.price}</h4>
                             </div>
-
                         </div>
                     </Link>
                 ))}

+ 2 - 0
src/components/Auth/authorisation.js

@@ -37,6 +37,7 @@ const Form = props => {
                         placeholder="Пароль"
                         className="input"
                     />
+
                     <div className="center">
                         <button className="buttonInAuth" onClick={handleSubmit(submit)}>
                             <Link to="/" className="colorLink" >Войти</Link>
@@ -44,6 +45,7 @@ const Form = props => {
                     </div>
                 </form>
             </div>
+
         </div>
 
 

+ 3 - 12
src/components/FormsAdd/FormAddNewStaff/SendingStaffForm.js

@@ -68,18 +68,16 @@ class SendingForm extends Component {
     }
 
     submit = values => {
-        const { AddNewStaffAction, getUser, photo } = this.props
-        //const { image } = this.state
 
-        if (!this.state.trig) {
+        const { AddNewStaffAction, getUser, photo } = this.props      
+        if(!this.state.trig){
+
             values.img = "http://rs.img.com.ua/crop?v2=1&w=600&h=0&url=%2F%2Fbm.img.com.ua%2Fberlin%2Fstorage%2Forig%2Fd224d3bd9bfe8bcb6b561da523d87364.jpg";
             values.state = 0
         } else {
             values.img = `http://127.0.0.1:2000/static/${photo.map(el => el.data.fileName)}`;
             values.state = 1
         }
-        //values.img = `http://127.0.0.1:2000/static/${photo.map(el => el.data.fileName)}`  
-
         values.staff = "Машина"
 
         values.userId = getUser.id
@@ -175,10 +173,3 @@ class SendingForm extends Component {
 export default reduxForm({
     form: 'SendingForm'
 })(SendingForm)
-// const mapStateToProps = (state, props) => ({
-//     form: props.formId
-//   });
-
-//   const component = reduxForm({ enableReinitialize: true })(SendingForm);
-
-//   export default connect(mapStateToProps)(component);

+ 34 - 21
src/components/FormsAdd/redForm/index.js

@@ -1,6 +1,6 @@
 import React, { Component } from 'react';
 import { Field, reduxForm } from 'redux-form';
-
+import { Link, Redirect } from "react-router-dom";
 import FormData from 'form-data'
 
 
@@ -46,10 +46,8 @@ class FormRedactorStaff extends  Component  {
         
     }
     send = () =>{
-        const { inputData, inputData1, inputData2, inputData3, match, photo, EditStaffAction, InfoStaff, getUser } = this.props
-        
+        const { inputData, inputData1, inputData2, inputData3, match, photo, EditStaffAction, InfoStaff, getUser } = this.props  
         let values = {}
-   
         if(!this.state.trig){
             values.img = "http://rs.img.com.ua/crop?v2=1&w=600&h=0&url=%2F%2Fbm.img.com.ua%2Fberlin%2Fstorage%2Forig%2Fd224d3bd9bfe8bcb6b561da523d87364.jpg";
             values.state = 0
@@ -58,32 +56,43 @@ class FormRedactorStaff extends  Component  {
             values.img = `http://127.0.0.1:2000/static/${photo.map(el => el.data.fileName)}`; 
             values.state = 1 
          }
-        values.staff = "Машина"
-        values.title = inputData
-        values.description = inputData1
-        values.price = inputData2
-        values.categoryId = inputData3
+            values.title = inputData
+            values.description = inputData1
+            values.price = inputData2
+            values.categoryId = inputData3  
+        values.staff = "Машина"       
         values.userId = getUser.id
         values.id = InfoStaff[0].id
-          //EditStaffAction(values)
-          console.log(values)
+        if(values.title === ""){
+            InfoStaff.map(el => values.title = el.title)
+        }
+        if(values.description === ""){
+            InfoStaff.map(el => values.description = el.description)
+        }
+        if(values.price === null){
+            InfoStaff.map(el => values.price = el.price)
+        }
+        if(values.categoryId === null){
+            InfoStaff.map(el => values.categoryId = el.categoryId)
+        }
+          EditStaffAction(values)
+        
+          //console.log(values)
     }
     render(){
         
         
          const { handleSubmit, pristine, reset, submitting, InfoStaff, photo, allCategory } = this.props
-         console.log("InfoStaff", InfoStaff)
+         
          const category = allCategory.data.filter(el => el.parentId !== 0)
          let data;
-         if(this.props.InfoStaff[0].id === this.props.match.params.id){
-             data = []
-         }
-         else{
+         
+         
             data = InfoStaff.map(el => <form  className="form">
             <input type="text"  name="title" defaultValue ={el.title} className="input" onChange={this.changeHandler}/>
             <textarea type="text"  name="description" defaultValue ={el.description} className="input" onChange={this.changeHandler1}/>
             <input type="number"  name="price" defaultValue ={el.price} className="input" onChange={this.changeHandler2}/>
-            <select type="number"  name="categoryId"  className="input" onChange={this.changeHandler3}>
+            <select type="number"  name="categoryId"  className="input" defaultValue ={el.categoryId} onChange={this.changeHandler3}>
 
               <option >Выберите рубрику</option>
                     {category.map(el => <option value={el.id}> {el.title}</option>)}
@@ -112,10 +121,10 @@ class FormRedactorStaff extends  Component  {
                         
                
                 <div className="buttonConteiner">
-                    <button type="button" className="button" onClick={this.send}>
+                <button type="button" className="button" onClick={this.send}>
                         Submit
                     </button>
-                    <button type="button" disabled={pristine || submitting} onClick={reset} className="button" >
+                   <button type="button" disabled={pristine || submitting} onClick={reset} className="button" >
                         Clear Values
                     </button>
                    
@@ -124,7 +133,7 @@ class FormRedactorStaff extends  Component  {
                 
             </form>
           )
-         }
+         
     return (
         
             <div className="formdiv">
@@ -137,4 +146,8 @@ class FormRedactorStaff extends  Component  {
 
 export default reduxForm({
     form: 'RedactorForm'
-})(FormRedactorStaff)
+})(FormRedactorStaff)
+
+// {!this.state.trig ?   <button type="button" className="button" onClick={this.send}>
+//                         Submit
+//                     </button>: <Redirect to='/' /> }

+ 15 - 0
src/components/Modal/addNewStaffModal.js

@@ -0,0 +1,15 @@
+import React, { Component } from "react";
+import { Modal } from "antd";
+
+export default class EditModal extends Component {
+	render() {
+		
+		
+		const { visible, onOk, onCancel, error, str } = this.props;
+		  return (
+			<Modal title="" visible={visible} onCancel={onCancel} onOk={onOk}  >
+					{error==="error" ? <h4>Не все поля были заполнены</h4> : <h4>{str}</h4>}
+			</Modal>
+		  );
+	}
+}

+ 9 - 9
src/components/Modal/index.js

@@ -2,14 +2,14 @@ import React, { Component } from "react";
 import { Modal } from "antd";
 
 export default class EditModal extends Component {
-    render() {
 
-        const { visible, onOk, onCancel, error } = this.props;
-        
-        return (
-            <Modal title="" visible={visible} onCancel={onCancel} onOk={onOk} >
-                {error === "error" ? <h4>Не все поля были заполнены</h4> : <h4>Ваше объявление успешно добавлено</h4>}
-            </Modal>
-        );
-    }
+	render() {	
+		const { visible, onOk, onCancel, str, inputData } = this.props;
+		  return (
+			<Modal title="" visible={visible} onCancel={onCancel} onOk={onOk}  >
+			<h4>{inputData ? str: "Данные введены не верно"}</h4>
+			</Modal>
+		  );
+	}
 }
+

+ 1 - 1
src/components/SearchStaffsPage/index.js

@@ -21,7 +21,7 @@ class searchStaffs extends Component {
                 data = <div className="staffs">
                       {searchData.map((el,key)=>(
                       <Link to = {`/search/Staff/${el.id}`}  key={key}  >
-                        <div className="staff" > {el.title} {el.price}  </div>
+                        <div className="staff" > {el.title} {el.price}  <img src={el.img} width="325" height="190" className="imgStaff"  alt="lorem" /></div>
                       </Link> 
                                                 )
                                     )}

+ 4 - 3
src/container/AddNewStaff.js

@@ -8,7 +8,7 @@ import { getUsersDataById } from "../actions/getUserById"
 import { bindActionCreators } from "redux";
 
 import FormAddNewStaff from '../components/FormsAdd/FormAddNewStaff';
-import EditModal from "../components/Modal";
+import EditModal from "../components/Modal/addNewStaffModal";
 
 class AddNewStaff extends Component {
     componentDidMount() {
@@ -27,8 +27,8 @@ class AddNewStaff extends Component {
         closeModal();
     }
     render() {
-        const { showModal, error, isFetching, AddNewStaffAction, getUser, photo, pushPhoto, base64, base64Photo, addOrnot } = this.props
-        console.log(base64Photo)
+        const { showModal, error } = this.props
+        const str = "Ваше объявление успешно добавлено"
         return (
 
             <Fragment>
@@ -41,6 +41,7 @@ class AddNewStaff extends Component {
                     onOk={this.closeEditModal}
                     onCancel={this.closeEditModal}
                     error={error}
+                    str={ str }
                 />
             </Fragment>
 

+ 1 - 0
src/container/UserProfile.js

@@ -57,6 +57,7 @@ class UserProfile extends Component {
                             </div>
                         </div>
                     </div>
+
                 </div>
             </Fragment>
 

+ 1 - 1
src/container/activeStaffs.js

@@ -13,7 +13,7 @@ import Header from '../container/Header'
 const axios = require('axios')
 
 class activeStaffs extends Component {
-
+ 
     componentDidMount() {
         const { getUsersDataById } = this.props
 

+ 20 - 6
src/container/redactorForm.js

@@ -1,10 +1,10 @@
-import React, { Component } from 'react';
+import React, { Component, Fragment } from 'react';
 import { getUsersDataById } from "../actions/getUserById"
 import { getCategoriesData } from '../actions/categoryAction';
 import { getStaffsDataById } from "../actions/getStaffByIdAction"
-import { pushPhoto, inputchangeHandler, inputchangeHandler1, inputchangeHandler2, inputchangeHandler3, EditStaffAction } from "../actions/addNewStaffAction"; 
+import { pushPhoto, inputchangeHandler, inputchangeHandler1, inputchangeHandler2, inputchangeHandler3, EditStaffAction, closeModal } from "../actions/addNewStaffAction"; 
 import FormRedactorStaff from '../components/FormsAdd/redForm'
-
+import EditModal from "../components/Modal/addNewStaffModal";
 import { connect} from 'react-redux';
 import { bindActionCreators } from "redux";
 
@@ -28,15 +28,28 @@ class redactorForm extends Component {
         }     
 
     }
+    closeEditModal = () => {
+        const { closeModal } = this.props;
+        closeModal();
+    }
     render() {
         const { allCategory } = this.props
+        const str = "Объявление успешно отредактировано"
         let data; 
         if (allCategory.data===undefined){
             data = []
         }
         else{ 
             const category = allCategory.data.filter(el => el.parentId !== 0)
-            data = <FormRedactorStaff {...this.props}/>
+            data = <Fragment>
+            <FormRedactorStaff {...this.props}/>  
+            <EditModal visible={this.props.showModal}
+            onOk={this.closeEditModal}
+            onCancel={this.closeEditModal}
+ 
+            str={ str }   
+        /> 
+                </Fragment>
         }
        
         return (
@@ -56,10 +69,11 @@ const mapStateToProps = state => ({
     inputData: state.addStaff.inputData,
     inputData1: state.addStaff.inputData1,
     inputData2: state.addStaff.inputData2,
-    inputData3: state.addStaff.inputData3
+    inputData3: state.addStaff.inputData3,
+    showModal: state.addStaff.showModal,
   });
   
-  const mapDispatchToProps = dispatch => bindActionCreators({ getUsersDataById, getStaffsDataById, getCategoriesData, pushPhoto, inputchangeHandler, inputchangeHandler1, inputchangeHandler2, inputchangeHandler3, EditStaffAction }, dispatch);
+  const mapDispatchToProps = dispatch => bindActionCreators({ closeModal, getUsersDataById, getStaffsDataById, getCategoriesData, pushPhoto, inputchangeHandler, inputchangeHandler1, inputchangeHandler2, inputchangeHandler3, EditStaffAction }, dispatch);
   
   export default redactorForm = connect(
         mapStateToProps,

+ 25 - 5
src/container/renderAuthorisation.js

@@ -3,26 +3,46 @@ import { bindActionCreators } from "redux";
 import { connect} from 'react-redux';
 
 import Form from "../components/Auth/authorisation";
+
 import LinkHome from "../components/Btn/linkHome"
-import { getUsersData } from "../actions/usersAuthActions";
 
-class RenderAuthorisation extends Component {      
+import { getUsersData, closeModal } from "../actions/usersAuthActions";
+
+
+import EditModal from "../components/Modal";
+
+class RenderAuthorisation extends Component { 
+  closeEditModal = () => {
+    const { closeModal } = this.props;
+    closeModal();
+}     
     render() {
+      const { showModal, inputData } = this.props
+      const str = "Данные введены верно";
+     
       return (
         <Fragment>
           <LinkHome />
-          <Form {...this.props} />
+          <Form {...this.props} /> 
+          <EditModal visible={showModal}
+                    onOk={this.closeEditModal}
+                    onCancel={this.closeEditModal}
+                    str={ str }
+                    inputData={ inputData }
+                />
         </Fragment>       
+
       );
     }
 }
 
 
 const mapStateToProps = state => ({
-  inputData: state.usersAuth.inputData
+  inputData: state.usersAuth.inputData,
+  showModal: state.usersAuth.showModal
 });
 
-const mapDispatchToProps = dispatch => bindActionCreators({ getUsersData }, dispatch);
+const mapDispatchToProps = dispatch => bindActionCreators({ getUsersData, closeModal }, dispatch);
 
 export default RenderAuthorisation = connect(
   mapStateToProps,

+ 16 - 2
src/container/renderRegistration.js

@@ -2,17 +2,29 @@ import React, { Component, Fragment } from "react";
 import { bindActionCreators } from "redux";
 import { connect } from 'react-redux';
 
-import * as actions from "../actions/usersRegistrActions";
 
+import { postUsersData, closeModal } from "../actions/usersRegistrActions";
+import EditModal from "../components/Modal";
 import RegistrForm from "../components/Auth/registration";
 import LinkHome from "../components/Btn/linkHome"
 
 class RenderRegistration extends Component {
+    closeEditModal = () => {
+        const { closeModal } = this.props;
+        closeModal();
+    } 
     render() {
+        const str = "Вы успешно зарегестрировались";
         return (
             <div className="formdiv">
                 <LinkHome />
                 <RegistrForm {...this.props} />
+                <EditModal visible={this.props.showModal}
+                    onOk={this.closeEditModal}
+                    onCancel={this.closeEditModal}
+                    str={ str }
+                    inputData={ this.props.inputData }
+                />
             </div>
         );
     }
@@ -20,9 +32,11 @@ class RenderRegistration extends Component {
 
 
 const mapStateToProps = state => ({
+    showModal: state.usersRegistr.showModal,
+    inputData: state.usersRegistr.inputData
 });
 
-const mapDispatchToProps = dispatch => bindActionCreators({ ...actions }, dispatch);
+const mapDispatchToProps = dispatch => bindActionCreators({ postUsersData, closeModal }, dispatch);
 
 export default RenderRegistration = connect(
     mapStateToProps,

+ 2 - 1
src/reducer/addStaff.js

@@ -35,7 +35,8 @@ export default ( state = initState, { type, payload } ) => {
                 ...state,
                 staffData: state.staffData.concat(JSON.parse(payload.config.data)),
                 isFetching:false,
-                showModal: true
+                showModal: true,
+                error: null
             }
         }
         case types.ADD_NEW_STAFF_REQUEST_FAIL: {

+ 11 - 2
src/reducer/usersAuthorisation.js

@@ -3,8 +3,9 @@ import * as types from "../constants/actionTypes";
 const initState = {
     inputData: [],
     isFetching: false,
-    error: null,
-    trig: true
+    
+    trig: true,
+    showModal: false
   };
 
 export default (state = initState, {type, payload} ) => {
@@ -29,6 +30,8 @@ export default (state = initState, {type, payload} ) => {
                 ...state,
                 inputData: payload.data,
                 isFatching: false,
+                showModal: true,
+                
             }
         }
         case types.USER_AUTH_REQUEST_FAIL: {
@@ -38,6 +41,12 @@ export default (state = initState, {type, payload} ) => {
                 error: "ERROR",
             }
         }
+        case types.CLOSE_MODAL_WINDOW: {
+            return {
+                ...state,
+                showModal: false
+            }
+        }
         
         
         default: return state;

+ 11 - 2
src/reducer/usersRegistration.js

@@ -3,10 +3,12 @@ import * as types from "../constants/actionTypes";
 const initState = {
     inputData: [],
     isFetching: false,
-    error: null
+    error: null,
+    showModal: false
   };
 
   export default (state = initState, { type, payload }) => {
+    console.log(payload)
       switch (type) {
         case types.USER_REG_REQUEST: {
           return {
@@ -20,7 +22,8 @@ const initState = {
           return {
             ...state,
             isFetching: false,
-            inputDate: payload.data
+            inputData: payload.data,
+            showModal: true
           }
         }
 
@@ -31,6 +34,12 @@ const initState = {
             error: "ERROR"
           }
         }
+        case types.CLOSE_MODAL_WINDOW: {
+          return {
+              ...state,
+              showModal: false
+          }
+      }
         
         default: return state;    
     }

+ 0 - 1
src/router.js

@@ -52,7 +52,6 @@ class Router extends Component {
             <Route path="/addCategory" exact component={AddNewCategory} />
             <Route path="/activeStaffs" exact component={ ActiveStaffs } />
             <Route path="/activeStaffs/:id" exact component={ redactorForm } />
-           
 	    </Switch>
     </Fragment>
        )

+ 1 - 1
src/utils/authValidate.js

@@ -2,8 +2,8 @@ export const authValidate =  values => {
     const { email, password } = values;
     const error = {};
 
-
     if(!email) {
+        
         error.email = "Required"
     } else if (!/^[A-Z0-9._%+-]+@[A-Z0-9.]+\.[A-Z]{2,4}$/i.test(email)) {
         error.email = 'Invalid email address'