Alex пре 5 година
родитељ
комит
c41ba08740

+ 0 - 40
src/actions/auth.js

@@ -91,46 +91,6 @@ export const getUser = () => dispatch => {
         .catch(err => dispatch(getUserRequestFail(err)));
 };
 
-const putUserRequest = payload => ({
-    type: types.PUT_USER_REQUEST,
-    payload
-});
-
-const putUserRequestSuccess = payload => ({
-    type: types.PUT_USER_REQUEST_SUCCESS,
-    payload
-});
-
-const putUserRequestFail = payload => ({
-    type: types.PUT_USER_REQUEST_FAIL,
-    payload
-});
-
-export const putUser = (payload) => dispatch => {
-    dispatch(putUserRequest());
-    return fetch(` https://api-clinics.herokuapp.com/api/v1/users/` + localStorage.getItem('userId'), {
-        method: "PUT",
-        credentials: "include",
-        headers: {
-            "Content-Type": "application/json"
-        },
-        body: JSON.stringify(payload.data)
-    })
-        .then(res => res.json())
-        .then(res => dispatch(putUserRequestSuccess(res)))
-        .catch(err => dispatch(putUserRequestFail(err)));
-};
-
-export const changeInputValueUserForm = payload => ({
-    type: types.CHANGE_INPUT_VALUE_USER_FORM,
-    payload
-});
-
-export const setBasicFormValue = payload => ({
-    type: types.USER_CHANGE_FORM_INFO,
-    payload
-})
-
 export const userLogout = payload => ({
     type: types.USER_LOGOUT,
     payload

+ 0 - 7
src/actionsTypes/actionsTypes.js

@@ -29,12 +29,6 @@ export const GET_USER_REQUEST = "GET_USER_REQUEST";
 export const GET_USER_REQUEST_SUCCESS = "GET_USER_REQUEST_SUCESS";
 export const GET_USER_REQUEST_FAIL = "GET_USER_REQUEST_FAIL";
 
-export const PUT_USER_REQUEST = "PUT_USER_REQUEST"
-export const PUT_USER_REQUEST_SUCCESS = "PUT_USER_REQUEST_SUCCESS"
-export const PUT_USER_REQUEST_FAIL = "PUT_USER_REQUEST_FAIL"
-
-export const CHANGE_INPUT_VALUE_USER_FORM = "CHANGE_INPUT_VALUE_USER_FORM"
-
 export const USER_LOGOUT = "USER_LOGOUT"
 
 export const POST_DOCTORS_REQUEST = "POST_DOCTORS_REQUEST";
@@ -86,7 +80,6 @@ export const GET_ORDERS_REQUEST_SUCCESS = "GET_ORDERS_REQUEST_SUCCESS";
 export const GET_ORDERS_REQUEST_FAIL = "GET_ORDERS_REQUEST_FAIL";
 export const USER_ORDERS = "USER_ORDERS"
 
-export const USER_CHANGE_FORM_INFO = "USER_CHANGE_FORM_INFO"
 
 
 

+ 3 - 15
src/components/userInfo.js

@@ -1,5 +1,5 @@
 import React from 'react';
-import Input from './Admin/Input'
+// import Input from './Admin/Input'
 
 
 class UserInfo extends React.Component {
@@ -8,25 +8,13 @@ class UserInfo extends React.Component {
  
     }
     render() { 
-        const { form, user, putItem,postItem, changeInputValues} = this.props
+        const { } = this.props
         // console.log('putItem', putItem)
         return ( 
             <div>
                 <div className="admin-item">
                     <form className="form-doctors" onSubmit={this.changeItem}>
-                        {
-                            form.map(el => {
-                                
-                                    return (
-                                        <Input
-                                            key={el.id}
-                                            id={el.id}
-                                            el={el}
-                                            changeInputValues={changeInputValues}
-                                        />
-                                    )
-                            })
-                        }
+               <div>Change user</div>
                         <input className="btn link"
                                type='submit'
                                value= 'Изменить'

+ 3 - 7
src/containers/user.js

@@ -7,7 +7,6 @@ import UserInfo from '../components/userInfo'
 import UserOrders from '../components/userOrders'
 
 import { getOrders,getUserOrders } from "../actions/orders"
-import { putUser,changeInputValueUserForm, setBasicFormValue } from '../actions/auth'
 
 class UserContainer extends Component {
 
@@ -23,7 +22,8 @@ class UserContainer extends Component {
     // }
 
     render() { 
-        const {currentUser,changeUserForm,changeInputValueUserForm, setBasicFormValue, dataOrders, getUserOrders} = this.props
+        // const {currentUser, dataOrders, getUserOrders} = this.props
+        const { currentUser } = this.props
         // console.log('user',currentUser)
         // console.log('Orders',dataOrders)
         return (
@@ -37,10 +37,6 @@ class UserContainer extends Component {
                     <Route path='/user/orders' component={ UserOrders } />
                     <Route path='/user/info' render={() => <UserInfo
                             user={currentUser}
-                            form={changeUserForm}
-                            putItem= {setBasicFormValue}
-                            postItem= {putUser}
-                            changeInputValues={changeInputValueUserForm}
                         />} />
                  </Switch>
                 </div>
@@ -57,4 +53,4 @@ const mapStateToProps = state => {
         changeUserForm: state.auth.changeUserForm
     }
 }
-export default connect(mapStateToProps, { getOrders, putUser,changeInputValueUserForm, setBasicFormValue,getUserOrders })(UserContainer);
+export default connect(mapStateToProps, { getOrders,getUserOrders })(UserContainer);

+ 0 - 53
src/reducers/auth.js

@@ -1,13 +1,10 @@
 import * as types from '../actionsTypes/actionsTypes'
 
-import {changeUserForm} from '../utils/formFields'
-
 const initialState = {
     user:{},
     isFetching: false,
     error:null,
     successRegister: null,
-    changeUserForm: changeUserForm
 }
 
 export default (state = initialState, action) => {
@@ -46,56 +43,6 @@ export default (state = initialState, action) => {
             return {...state,isFetching: false, user: action.payload.user}
         }
 
-        case types.CHANGE_INPUT_VALUE_USER_FORM : {
-            console.log(action.payload)
-            return { ...state,
-                changeUserForm: state.changeUserForm.map(el => el.id === +action.payload.target.id ? {
-                ...el,
-                
-                value: action.payload.target.value
-            } : el)
-        }
-        }
-        case types.PUT_USER_REQUEST : {
-            return {
-                ...state,
-                isFetching: true
-            };
-        }
-
-        case types.USER_CHANGE_FORM_INFO: {
-            const {data} = action.payload
-            console.log(data)
-          
-           
-            return {
-                ...state,
-                // changeUserForm:state.changeUserForm.map(el => 
-                //     el.name === data.name  ?  {                   
-                //          ...el,                   
-                //          value:data.value
-                //      } :
-                //      el)
-
-            }
-        }
-
-        case types.PUT_USER_REQUEST_SUCCESS : {
-            return {
-                ...state,
-                changeUserForm:changeUserForm,
-                isFetching: false
-            }
-        }
-
-        case types.PUT_USER_REQUEST_FAIL : {
-            return {
-                ...state,
-                error: action.payload,
-                isFetching: false
-            }
-        }
-        
         case types.USER_LOGOUT: {
             return { ...state, user: initialState.user}
         }

+ 0 - 44
src/utils/formFields.js

@@ -231,50 +231,6 @@ export const postNewServiceForm =[
 	}
 ];
 
-export const changeUserForm = [
-	{
-		id:1,
-		type:'text',
-		value:"",
-		name:'firstName',
-		placeholder:'Введите Имя',
-		required:true
-	},
-	{
-		id:2,
-		type:'text',
-		value:"",
-		name:'lastName',
-		placeholder:'Введите Фамилию',
-		required:true
-	},
-	{
-		id:3,
-		type:'number',
-		value:"",
-		name:'phone',
-		placeholder:'Введите ваш номер',
-		required:true
-	},
-	{
-		id:4,
-		type:'password',
-		value:"",
-		name:'password',
-		placeholder:'Введите новый пароль',
-		required:true
-	},
-	{
-		id:5,
-		type:'password',
-		value:"",
-		name:'confirmPassword',
-		placeholder:'Повторите пароль',
-		required:true
-	}
-	
-];
-
 export const route = [
 	{
 		id: 1,