Browse Source

Merge branch 'dev' of http://gitlab.a-level.com.ua/Entony/FEA_12_CLINIC into mila

Mila-Zagrevskaya 5 years ago
parent
commit
2bc51f0a5c

+ 3 - 164
src/actions/actions.js

@@ -38,13 +38,6 @@ export const changeSpecialityArray = payload => ({
     payload
 });
 
-// -----------------------------------------------------------------------------------------------------------------
-
-export const setSheduleDoctor = payload => ({
-    type: types.CHANGE_SHEDULE_DOCTOR,
-    payload
-});
-
 // -----------------------------------------------------------------------------------------------------------------
 // -----------------------------------------------------------------------------------------------------------------
 
@@ -76,34 +69,6 @@ export const getDoctors = () => dispatch => {
 
 // -----------------------------------------------------------------------------------------------------------------
 
-// const getServicesRequest = payload => ({
-//     type: types.GET_SERVICES_REQUEST,
-//     payload
-// });
-//
-// const getServicesRequestSuccess = payload => ({
-//     type: types.GET_SERVICES_REQUEST_SUCCESS,
-//     payload
-// });
-//
-// const getServicesRequestFail = payload => ({
-//     type: types.GET_SERVICES_REQUEST_FAIL,
-//     payload
-// });
-//
-// export const getServices = () => dispatch => {
-//     dispatch(getServicesRequest());
-//     return fetch(`${URL}services`,{
-//         credentials:"include"
-//     })
-//         .then(res => res.json())
-//         .then(res => dispatch(getServicesRequestSuccess(res)))
-//         .catch(err => dispatch(getServicesRequestFail(err)));
-// };
-
-// -----------------------------------------------------------------------------------------------------------------
-// -----------------------------------------------------------------------------------------------------------------
-
 const postDoctorsRequest = payload => ({
     type: types.POST_DOCTORS_REQUEST,
     payload
@@ -130,77 +95,12 @@ export const postDoctors = (payload) => dispatch => {
         body: JSON.stringify(payload)
     })
         .then(res => res.json())
-        .then(res => dispatch(postDoctorsRequestSuccess(res)))
+        .then(res => dispatch(postDoctorsRequestSuccess(res))).then(dispatch(getDoctors()))
         .catch(err => dispatch(postDoctorsRequestFail(err)));
 };
 
 // -----------------------------------------------------------------------------------------------------------------
 
-const postServicesRequest = payload => ({
-    type: types.POST_SERVICES_REQUEST,
-    payload
-});
-
-const postServicesRequestSuccess = payload => ({
-    type: types.POST_SERVICES_REQUEST_SUCCESS,
-    payload
-});
-
-const postServicesRequestFail = payload => ({
-    type: types.POST_SERVICES_REQUEST_FAIL,
-    payload
-});
-
-export const postServices = (payload) => dispatch => {
-    dispatch(postServicesRequest());
-    return fetch(`${URL}services`, {
-        method: "POST",
-        credentials: "include",
-        headers: {
-            "Content-Type": "application/json"
-        },
-        body: JSON.stringify(payload)
-    })
-        .then(res => res.json())
-        .then(res =>  dispatch(postServicesRequestSuccess(res)))
-        .catch(err => dispatch(postServicesRequestFail(err)))
-};
-
-// -----------------------------------------------------------------------------------------------------------------
-
-const postSheduleRequest = payload => ({
-    type: types.POST_SHEDULE_REQUEST,
-    payload
-});
-
-const postSheduleSuccess = payload => ({
-    type: types.POST_SHEDULE_REQUEST_SUCCESS,
-    payload
-});
-
-const postSheduleFail = payload => ({
-    type: types.POST_SHEDULE_REQUEST_FAIL,
-    payload
-});
-
-export const postShedule = (payload) => dispatch => {
-    dispatch(postSheduleRequest());
-    return fetch(`${URL}shedule`, {
-        method: "POST",
-        credentials:"include",
-        headers: {
-            'Content-Type': 'application/json'
-        },
-        body: JSON.stringify(payload)
-    })
-        .then(res => res.json())
-        .then(res => dispatch(postSheduleSuccess(res))).then(dispatch(getDoctors()))
-        .catch(err => dispatch(postSheduleFail(err)));
-};
-
-// -----------------------------------------------------------------------------------------------------------------
-// -----------------------------------------------------------------------------------------------------------------
-
 const putDoctorsRequest = payload => ({
     type: types.PUT_DOCTORS_REQUEST,
     payload
@@ -227,73 +127,12 @@ export const putDoctors = (payload) => dispatch => {
         body: JSON.stringify(payload.data)
     })
         .then(res => res.json())
-        .then(res => dispatch(putDoctorsRequestSuccess(res)))
+        .then(res => dispatch(putDoctorsRequestSuccess(res))).then(dispatch(getDoctors()))
         .catch(err => dispatch(putDoctorsRequestFail(err)));
 };
 
 // -----------------------------------------------------------------------------------------------------------------
 
-const putServicesRequest = payload => ({
-    type: types.PUT_SERVICES_REQUEST,
-    payload
-});
-
-const putServicesRequestSuccess = payload => ({
-    type: types.PUT_SERVICES_REQUEST_SUCCESS,
-    payload
-});
-
-const putServicesRequestFail = payload => ({
-    type: types.PUT_SERVICES_REQUEST_FAIL,
-    payload
-});
-
-export const putServices = (payload) => dispatch => {
-    dispatch(putServicesRequest());
-    return fetch(`${URL}services/${payload.id}`, {
-        method: "PUT",
-        credentials: "include",
-        headers: {
-            "Content-Type": "application/json"
-        },
-        body: JSON.stringify(payload.data)
-    })
-        .then(res => res.json())
-        .then(res => dispatch(putServicesRequestSuccess(res)))
-        .catch(err => dispatch(putServicesRequestFail(err)));
-};
-
-// -----------------------------------------------------------------------------------------------------------------
-// -----------------------------------------------------------------------------------------------------------------
-
-const deleteServicesRequest = payload => ({
-    type: types.DELETE_DOCTORS_REQUEST,
-    payload
-});
-
-const deleteServicesRequestSuccess = payload => ({
-    type: types.DELETE_DOCTORS_REQUEST_SUCCESS,
-    payload
-});
-
-const deleteServicesRequestFail = payload => ({
-    type: types.DELETE_DOCTORS_REQUEST_FAIL,
-    payload
-});
-
-export const deleteServices = (payload) => dispatch => {
-    dispatch(deleteServicesRequest());
-    return fetch(`${URL}services/${payload}`, {
-        method: "DELETE",
-        credentials: "include"
-    })
-        .then(res => res.json())
-        .then(res => dispatch(deleteServicesRequestSuccess(res)))
-        .catch(err => dispatch(deleteServicesRequestFail(err)));
-};
-
-// -----------------------------------------------------------------------------------------------------------------
-
 const deleteDoctorsRequest = payload => ({
     type: types.DELETE_DOCTORS_REQUEST,
     payload
@@ -316,7 +155,7 @@ export const deleteDoctors = (payload) => dispatch => {
         credentials: "include"
     })
         .then(res => res.json())
-        .then(res => dispatch(deleteDoctorsRequestSuccess(res)))
+        .then(res => dispatch(deleteDoctorsRequestSuccess(res))).then(dispatch(getDoctors()))
         .catch(err => dispatch(deleteDoctorsRequestFail(err)));
 };
 

+ 93 - 0
src/actions/services.js

@@ -2,6 +2,7 @@ import * as types from "../actionsTypes/actionsTypes";
 
 const URL = "https://api-clinics.herokuapp.com/api/v1/";
 
+
 const getServicesRequest = payload => ({
     type: types.GET_SERVICES_REQUEST,
     payload
@@ -27,7 +28,99 @@ export const getServices = () => dispatch => {
         .catch(err => dispatch(getServicesRequestFail(err)));
 };
 
+// -----------------------------------------------------------------------------------------------------------------
+
+const postServicesRequest = payload => ({
+    type: types.POST_SERVICES_REQUEST,
+    payload
+});
+
+const postServicesRequestSuccess = payload => ({
+    type: types.POST_SERVICES_REQUEST_SUCCESS,
+    payload
+});
+
+const postServicesRequestFail = payload => ({
+    type: types.POST_SERVICES_REQUEST_FAIL,
+    payload
+});
+
+export const postServices = (payload) => dispatch => {
+    dispatch(postServicesRequest());
+    return fetch(`${URL}services`, {
+        method: "POST",
+        credentials: "include",
+        headers: {
+            "Content-Type": "application/json"
+        },
+        body: JSON.stringify(payload)
+    })
+        .then(res => res.json())
+        .then(res =>  dispatch(postServicesRequestSuccess(res))).then(dispatch(getServices()))
+        .catch(err => dispatch(postServicesRequestFail(err)))
+};
+
+// -----------------------------------------------------------------------------------------------------------------
+
+const putServicesRequest = payload => ({
+    type: types.PUT_SERVICES_REQUEST,
+    payload
+});
+
+const putServicesRequestSuccess = payload => ({
+    type: types.PUT_SERVICES_REQUEST_SUCCESS,
+    payload
+});
+
+const putServicesRequestFail = payload => ({
+    type: types.PUT_SERVICES_REQUEST_FAIL,
+    payload
+});
+
+export const putServices = (payload) => dispatch => {
+    dispatch(putServicesRequest());
+    return fetch(`${URL}services/${payload.id}`, {
+        method: "PUT",
+        credentials: "include",
+        headers: {
+            "Content-Type": "application/json"
+        },
+        body: JSON.stringify(payload.data)
+    })
+        .then(res => res.json())
+        .then(res => dispatch(putServicesRequestSuccess(res))).then(dispatch(getServices()))
+        .catch(err => dispatch(putServicesRequestFail(err)));
+};
+
+// -----------------------------------------------------------------------------------------------------------------
+
+const deleteServicesRequest = payload => ({
+    type: types.DELETE_DOCTORS_REQUEST,
+    payload
+});
+
+const deleteServicesRequestSuccess = payload => ({
+    type: types.DELETE_DOCTORS_REQUEST_SUCCESS,
+    payload
+});
+
+const deleteServicesRequestFail = payload => ({
+    type: types.DELETE_DOCTORS_REQUEST_FAIL,
+    payload
+});
+
+export const deleteServices = (payload) => dispatch => {
+    dispatch(deleteServicesRequest());
+    return fetch(`${URL}services/${payload}`, {
+        method: "DELETE",
+        credentials: "include"
+    })
+        .then(res => res.json())
+        .then(res => dispatch(deleteServicesRequestSuccess(res))).then(dispatch(getServices()))
+        .catch(err => dispatch(deleteServicesRequestFail(err)));
+};
 
+// -----------------------------------------------------------------------------------------------------------------
 
 const getCategoriesRequest = payload => ({
     type: types.GET_CATEGORIES_REQUEST,

+ 46 - 0
src/actions/shedule.js

@@ -0,0 +1,46 @@
+import * as types from '../actionsTypes/actionsTypes'
+import {getDoctors} from "./actions";
+
+
+export const setSheduleDoctor = payload => ({
+    type: types.CHANGE_SHEDULE_DOCTOR,
+    payload
+});
+
+// -----------------------------------------------------------------------------------------------------------------
+
+const postSheduleRequest = payload => ({
+    type: types.POST_SHEDULE_REQUEST,
+    payload
+});
+
+// -----------------------------------------------------------------------------------------------------------------
+
+const postSheduleSuccess = payload => ({
+    type: types.POST_SHEDULE_REQUEST_SUCCESS,
+    payload
+});
+
+// -----------------------------------------------------------------------------------------------------------------
+
+const postSheduleFail = payload => ({
+    type: types.POST_SHEDULE_REQUEST_FAIL,
+    payload
+});
+
+// -----------------------------------------------------------------------------------------------------------------
+
+export const postShedule = (payload) => dispatch => {
+    dispatch(postSheduleRequest());
+    return fetch(`${URL}shedule`, {
+        method: "POST",
+        credentials:"include",
+        headers: {
+            'Content-Type': 'application/json'
+        },
+        body: JSON.stringify(payload)
+    })
+        .then(res => res.json())
+        .then(res => dispatch(postSheduleSuccess(res))).then(dispatch(getDoctors()))
+        .catch(err => dispatch(postSheduleFail(err)));
+};

+ 8 - 4
src/actions/user.js

@@ -86,11 +86,15 @@ const putUserRequestFail = payload => ({
 
 export const putUser = (payload) => dispatch => {
     dispatch(putUserRequest());
-    return fetch(`${URL}${payload}`, {
-        method: "DELETE",
-        credentials: "include"
+    return fetch(`${URL}${payload.path}`, {
+        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)));
-};
+};

+ 19 - 9
src/components/Admin/Admin.js

@@ -3,8 +3,6 @@ import {connect} from 'react-redux'
 import {Link} from 'react-router-dom'
 import {Switch, Route} from "react-router-dom";
 import {
-    setSheduleDoctor,
-    postShedule,
     changeInputValueDoctorForm,
     changeInputValueServiceForm,
     postDoctors,
@@ -12,9 +10,6 @@ import {
     changeSelectedServiceId,
     putDoctors,
     deleteDoctors,
-    postServices,
-    putServices,
-    deleteServices,
     changeSpecialityArray
 } from "../../actions/actions";
 
@@ -22,9 +17,21 @@ import {
     changeFindUserInput,
     findUser,
     deleteUser,
-    changeInputValueUserForm
+    changeInputValueUserForm,
+    putUser
 } from "../../actions/user"
 
+import {
+    postServices,
+    putServices,
+    deleteServices
+} from "../../actions/services"
+
+import {
+    setSheduleDoctor,
+    postShedule,
+} from "../../actions/shedule"
+
 import Shedule from './Shedule'
 import ChangeUser from './ChangeUser'
 import ChangeServicesDoctors from './ChangeServices-Doctors'
@@ -64,7 +71,8 @@ export class Admin extends React.Component {
             deleteUser,
             userError,
             changeUserForm,
-            changeInputValueUserForm
+            changeInputValueUserForm,
+            putUser
         } = this.props;
 
         return (
@@ -115,6 +123,7 @@ export class Admin extends React.Component {
                             error={userError}
                             changeUserForm={changeUserForm}
                             changeInputValueUserForm={changeInputValueUserForm}
+                            putUser={putUser}
                         />} />
                     </Switch>
                 </div>
@@ -126,7 +135,7 @@ export class Admin extends React.Component {
 const mapStateToProps = state => {
     return {
         doctors:state.app.doctors,
-        postNewShedule:state.app.postNewShedule,
+        postNewShedule:state.shedule.postNewShedule,
         postNewDoctor:state.app.postNewDoctor,
         postNewService:state.app.postNewService,
         changeDoctorId:state.app.changeDoctorId,
@@ -158,7 +167,8 @@ const mapDispatchToProps = {
     changeFindUserInput,
     findUser,
     deleteUser,
-    changeInputValueUserForm
+    changeInputValueUserForm,
+    putUser
 };
 
 export default connect (mapStateToProps,mapDispatchToProps)(Admin)

+ 17 - 19
src/components/Admin/ChangeServices-Doctors.js

@@ -14,10 +14,6 @@ export default class ChangeServicesDoctors extends React.Component {
         this.setState({showConfirm: !this.state.showConfirm})
     };
 
-    componentDidUpdate(prevProps) {
-        if (this.props.data !== prevProps.data) this.setState({flag: false})
-    };
-
     changeFlag = (e) => {
         e.preventDefault();
         this.setState({flag: !this.state.flag})
@@ -50,7 +46,6 @@ export default class ChangeServicesDoctors extends React.Component {
             } : obj,
             id: this.props.itemId
         })
-
     };
 
     deleteItem = () => {
@@ -59,12 +54,10 @@ export default class ChangeServicesDoctors extends React.Component {
     };
 
     changeId = (e) => {
-        console.log ("data", this.props.data)
         this.props.changeId({
-            item: e.target,
+            item: e,
             data: this.props.data,
         })
-        
     };
 
     render() {
@@ -77,14 +70,16 @@ export default class ChangeServicesDoctors extends React.Component {
             changeSpecialityArray,
             specialityArray
         } = this.props;
-        let doctor = data.find(el => el._id === itemId);
-        if (doctor) doctor = doctor.speciality;
-        // console.log(data,specialityArray)
         return (
             <div className="change-services-doctors">
                 {this.state.flag &&
-                <CheckBoxWindow categories={categories} specialityArray={specialityArray} changeFlag={this.changeFlag}
-                                changeSpecialityArray={changeSpecialityArray}/>}
+                <CheckBoxWindow
+                    categories={categories}
+                    specialityArray={specialityArray}
+                    changeFlag={this.changeFlag}
+                    changeSpecialityArray={changeSpecialityArray}
+                />
+                }
                 <div className="admin-item">
                     <form className="form-doctors" onSubmit={itemId ? this.changeItem : this.postNewItem}>
                         {
@@ -103,14 +98,14 @@ export default class ChangeServicesDoctors extends React.Component {
                         }
                         {categories &&
                         <button className=" btn servise-btn" onClick={this.changeFlag}>Выбрать сервисы</button>}
-                        <input className="btn link"
-                               type='submit'
-                               value={itemId ? 'Изменить' : 'Добавить'}
+                        <input
+                            className="btn link"
+                            type='submit'
+                            value={itemId ? 'Изменить' : 'Добавить'}
                         />
                     </form>
                 </div>
                 <div className="admin-item">
-
                     <CustomSelect
                         // label="Выбрать"
                         options={data}
@@ -123,8 +118,11 @@ export default class ChangeServicesDoctors extends React.Component {
                     }
                 </div>
                 {this.state.showConfirm &&
-                <ConfirmButton yes={this.deleteItem} no={this.changeConfirm}
-                               text={'Are you sure you want to Delete Item?'}/>
+                <ConfirmButton
+                    yes={this.deleteItem}
+                    no={this.changeConfirm}
+                    text={'Are you sure you want to Delete Item?'}
+                />
                 }
             </div>
         );

+ 2 - 2
src/components/Admin/ChangeUser.js

@@ -30,7 +30,7 @@ export default class ChangeUser extends React.Component {
         this.props.changeUserForm.map(el => {
             obj[el.name] = el.type === 'radio' ? el.checked ? el.value : !el.value : el.value
         });
-        console.log(obj) //заменить на putUsers
+        this.props.putUser({data:obj,path:this.props.user._id})
     };
 
     changeConfirm = (action, text) => {
@@ -38,7 +38,7 @@ export default class ChangeUser extends React.Component {
     };
 
     deleteUser = (e) => {
-        console.log(this.props.user._id); // заменить на deleteUser
+        this.props.deleteUser(this.props.user._id);
         this.changeConfirm()
     };
 

+ 1 - 0
src/components/Admin/Input.js

@@ -16,6 +16,7 @@ export default class Input extends React.Component {
                 required={el.required}
                 pattern={el.pattern}
                 checked={el.checked}
+                readOnly={el.readOnly}
                 onChange={(e) => changeInputValues(e)}
             />
         );

+ 2 - 3
src/components/Admin/Shedule.js

@@ -11,7 +11,7 @@ export default class Shedule extends React.Component {
     };
 
     post = (e) => {
-        e.preventDefault()
+        e.preventDefault();
         let current = new Date(this.state.startDate);
         let end = new Date (this.state.endDate);
         while (current.toISOString().split('T')[0] <= end.toISOString().split('T')[0]){
@@ -32,8 +32,7 @@ export default class Shedule extends React.Component {
         this.setState ( { endDate:e.target.value } )
     };
     setDoctor = (e) => {
-        console.log (e)
-        this.props.setSheduleDoctor(e)
+        this.props.setSheduleDoctor({data:e,doctors:this.props.doctors})
   
     };
 

+ 3 - 1
src/reducers/index.js

@@ -6,6 +6,7 @@ import auth from './auth';
 import {appointmentReducer} from "./appointment";
 import {servicesReducer} from "./services";
 import {userReducer} from "./user";
+import {sheduleReducer} from "./shedule";
 
 
 
@@ -15,5 +16,6 @@ export default combineReducers({
     calendar:calendarReducer,
     appointment:appointmentReducer,
     services:servicesReducer,
-    user:userReducer
+    user:userReducer,
+    shedule:sheduleReducer
 })

+ 8 - 104
src/reducers/reducers.js

@@ -5,15 +5,6 @@ import {postNewDoctorForm,postNewServiceForm} from '../utils/formFields'
 const defaultState = {
     doctors:[],
 
-    orders:[],
-    users:[],
-    reviews: [],
-
-    postNewShedule:{
-        data:null,
-        doctor:null
-    },
-
     postNewDoctor:postNewDoctorForm,
     postNewService:postNewServiceForm,
     changeDoctorId:null,
@@ -22,7 +13,6 @@ const defaultState = {
 
     isFetching:false,
     error: null,
-
 };
 
 // -----------------------------------------------------------------------------------------------------------------
@@ -71,21 +61,14 @@ export const appReducer = (state = defaultState,action) => {
 
         case types.CHANGE_SELECTED_DOCTOR_ID : {
             let doctor = action.payload.data.find(el => el.name === action.payload.item);
-            let result;
             let specArray=[];
-            if (doctor){
-                result = Object.keys(doctor).map(key => {
-                    return [key, doctor[key]];
-                });
-                doctor.speciality.map(el => specArray.push(el._id))
-            }
             return {
                 ...state,
                 specialityArray:specArray,
                 changeDoctorId: doctor ? doctor._id : null,
-                postNewDoctor:doctor ? state.postNewDoctor.map(el => result.find(item => item[0] === el.name) ? {
+                postNewDoctor:doctor ? state.postNewDoctor.map(el => Object.keys(doctor).find(item => item === el.name) ? {
                     ...el,
-                    value:result.find(item => item[0] === el.name)[1]
+                    value:doctor[el.name]
                 } : el) : postNewDoctorForm
             };
         }
@@ -94,41 +77,16 @@ export const appReducer = (state = defaultState,action) => {
 
         case types.CHANGE_SELECTED_SERVICE_ID : {
             let service = action.payload.data.find(el => el.name === action.payload.item);
-            let result;
-                if (service){
-                    result = Object.keys(service).map(key => {
-                        return [key, service[key]];
-                    });
-                }
             return {
                 ...state,
                 changeServiceId: service ? service._id : null,
-                postNewService: service ? state.postNewService.map(el => result.find(item => item[0] === el.name) ? {
+                postNewService: service ? state.postNewService.map(el => Object.keys(service).find(item => item === el.name) ? {
                     ...el,
-                    value:result.find(item => item[0] === el.name)[1]
+                    value:service[el.name]
                 } : el) : postNewServiceForm
             };
         }
 
-// -----------------------------------------------------------------------------------------------------------------
-
-        case types.CHANGE_SHEDULE_DOCTOR : {
-            let doctor = state.doctors.find(el=>el.name === action.payload);
-            let array = [[],[],[],[],[],[],[],[],[],[],[],[]];
-            // eslint-disable-next-line array-callback-return
-            doctor.shedule.map(el => {
-                array[new Date(el.data).getMonth()].push(el)
-            });
-            return {
-                ...state,
-                postNewShedule: {
-                    ...state.postNewShedule,
-                    doctor:doctor._id
-                },
-                sheduleMonthArray: array
-            };
-        }
-
 // -----------------------------------------------------------------------------------------------------------------
 // -----------------------------------------------------------------------------------------------------------------
 
@@ -155,8 +113,6 @@ export const appReducer = (state = defaultState,action) => {
             }
         }
 
-
-
 // -----------------------------------------------------------------------------------------------------------------
 // -----------------------------------------------------------------------------------------------------------------
 
@@ -183,58 +139,6 @@ export const appReducer = (state = defaultState,action) => {
             }
         }
 
-// -----------------------------------------------------------------------------------------------------------------
-
-        case types.POST_SHEDULE_REQUEST : {
-            return {
-                ...state,
-                isFetching: true
-            };
-        }
-
-        case types.POST_SHEDULE_REQUEST_SUCCESS : {
-            return {
-                ...state,
-                postNewShedule:{
-                    ...state.postNewShedule,
-                    data:null,
-                },
-                isFetching: false
-            }
-        }
-
-        case types.POST_SHEDULE_REQUEST_FAIL : {
-            return {
-                ...state,
-                error: action.payload,
-                isFetching: false
-            }
-        }
-
-// -----------------------------------------------------------------------------------------------------------------
-
-        case types.POST_SERVICES_REQUEST : {
-            return {
-                ...state,
-                isFetching: true
-            };
-        }
-
-        case types.POST_SERVICES_REQUEST_SUCCESS : {
-            return {
-                ...state,
-                isFetching: false
-            }
-        }
-
-        case types.POST_SERVICES_REQUEST_FAIL : {
-            return {
-                ...state,
-                error: action.payload,
-                isFetching: false
-            }
-        }
-
 // -----------------------------------------------------------------------------------------------------------------
 
         case types.POST_ORDERS_REQUEST : {
@@ -273,7 +177,7 @@ export const appReducer = (state = defaultState,action) => {
             return {
                 ...state,
                 postNewDoctor:postNewDoctorForm,
-                changeId:null,
+                changeDoctorId:null,
                 isFetching: false
             }
         }
@@ -299,7 +203,7 @@ export const appReducer = (state = defaultState,action) => {
             return {
                 ...state,
                 postNewService:postNewServiceForm,
-                changeId:null,
+                changeServiceId:null,
                 isFetching: false
             }
         }
@@ -325,7 +229,7 @@ export const appReducer = (state = defaultState,action) => {
         case types.DELETE_DOCTORS_REQUEST_SUCCESS : {
             return {
                 ...state,
-                changeId:null,
+                changeDoctorId:null,
                 isFetching: false
             }
         }
@@ -350,7 +254,7 @@ export const appReducer = (state = defaultState,action) => {
         case types.DELETE_SERVICES_REQUEST_SUCCESS : {
             return {
                 ...state,
-                changeId:null,
+                changeServiceId:null,
                 isFetching: false
             }
         }

+ 24 - 0
src/reducers/services.js

@@ -33,6 +33,30 @@ export const servicesReducer = (state = defaultState, action) => {
             }
         }
 
+
+        case types.POST_SERVICES_REQUEST : {
+            return {
+                ...state,
+                isFetching: true
+            };
+        }
+
+        case types.POST_SERVICES_REQUEST_SUCCESS : {
+            return {
+                ...state,
+                isFetching: false
+            }
+        }
+
+        case types.POST_SERVICES_REQUEST_FAIL : {
+            return {
+                ...state,
+                error: action.payload,
+                isFetching: false
+            }
+        }
+
+
         case types.GET_CATEGORIES_REQUEST : {
             return {
                 ...state,

+ 55 - 0
src/reducers/shedule.js

@@ -0,0 +1,55 @@
+import * as types from '../actionsTypes/actionsTypes'
+
+const defaultState = {
+    postNewShedule:{
+        data:null,
+        doctor:null
+    },
+    isFetching: false,
+    error:null
+};
+
+export const sheduleReducer = (state = defaultState, action) => {
+    switch(action.type){
+
+        case types.CHANGE_SHEDULE_DOCTOR : {
+            let doctor = action.payload.doctors.find(el=>el.name === action.payload.data);
+            return {
+                ...state,
+                postNewShedule: {
+                    ...state.postNewShedule,
+                    doctor:doctor._id
+                },
+            };
+        }
+
+        case types.POST_SHEDULE_REQUEST : {
+            return {
+                ...state,
+                isFetching: true
+            };
+        }
+
+        case types.POST_SHEDULE_REQUEST_SUCCESS : {
+            return {
+                ...state,
+                postNewShedule:{
+                    ...state.postNewShedule,
+                    data:null,
+                },
+                isFetching: false
+            }
+        }
+
+        case types.POST_SHEDULE_REQUEST_FAIL : {
+            return {
+                ...state,
+                error: action.payload,
+                isFetching: false
+            }
+        }
+
+        default:
+            return state
+    }
+};

+ 2 - 0
src/utils/formFields.js

@@ -255,6 +255,7 @@ export const adminChangeUserForm =[
 		value:"",
 		name:'email',
 		placeholder:'Введите E-mail',
+		readOnly:true,
 		required:true
 	},
 	{
@@ -270,6 +271,7 @@ export const adminChangeUserForm =[
 		type:'text',
 		value:"",
 		name:'_id',
+		readOnly:true,
 		required:true
 	},
 	{