Boris K 5 years ago
parent
commit
625ef04201

+ 1 - 0
src/App.js

@@ -128,6 +128,7 @@ export class App extends React.Component {
     }
 
     render() {
+        console.log(this.props.app)
         return (
               <Loader flag={this.props.app.isFetching}>
                     <Header/>

+ 45 - 45
src/components/Admin/ChangeServices-Doctors.js

@@ -3,35 +3,48 @@ import Input from './Input'
 
 export default class ChangeServicesDoctors extends React.Component {
 
+    postNewItem = (e) => {
+        const obj = {};
+        e.preventDefault();
+        this.props.form.map(el => {
+            obj[el.name] = el.value
+        });
+        this.props.postItem(obj)
+    };
 
-    render() {
+    changeItem = (e) => {
         const obj = {};
+        e.preventDefault();
+        this.props.form.map(el => {
+            if (el.value !== '')
+                obj[el.name] = el.value
+        });
+        this.props.putItem({data:obj,id:this.props.itemId})
+
+    };
+
+    deleteItem = () => {
+        this.props.deleteItem(this.props.itemId)
+    };
+
+    changeId = (e) => {
+        this.props.changeId(e.target.value)
+    };
+
+    render() {
         const {
             data,
             itemId,
             form,
-            postItem,
-            putItem,
-            deleteItem,
-            changeId,
             changeInputValues,
         } = this.props;
         return (
-
             <div className = "change-services-doctors">
                 <div className="admin-item">
-                    <form className ="form-doctors"   onSubmit={(e)=>{
-                        e.preventDefault();
-                        // eslint-disable-next-line array-callback-return
-                        form.map(el => {
-                            obj[el.name] = el.value
-                        });
-                        postItem(obj)
-                    }}
-                    >
+                    <form className ="form-doctors" onSubmit={this.postNewItem}>
                         {
                             form.map(el => (
-                                <Input 
+                                <Input
                                     key={el.id}
                                     id={el.id}
                                     el={el}
@@ -39,15 +52,14 @@ export default class ChangeServicesDoctors extends React.Component {
                                 />
                             ))
                         }
-                        <input className = "btn link" 
-                            type='submit'
-                            value='Добавить '
+                        <input className = "btn link"
+                               type='submit'
+                               value='Добавить '
                         />
                     </form>
                 </div>
-
                 <div className="admin-item">
-                    <select  className = "appointment admin-form"  onChange={(e)=>changeId(e.target.value)} defaultValue='Выбрать'>
+                    <select  className = "appointment admin-form"  onChange={this.changeId} defaultValue='Выбрать'>
                         <option disabled >Выбрать</option>
                         {
                             data.map(el=> (
@@ -55,23 +67,9 @@ export default class ChangeServicesDoctors extends React.Component {
                             ))
                         }
                     </select>
-                    {itemId &&
-                    <button className = "btn link" onClick={()=>deleteItem(itemId)} style={{backgroundColor:"#ff9774"}}>Удалить карточку сотрудника</button>
-                    }
 
-                    {
-                        <form  onSubmit={(e)=>{
-                            e.preventDefault();
-                            // eslint-disable-next-line array-callback-return
-                            form.map(el => {
-                                if (el.value !== '')
-                                    obj[el.name] = el.value
-                            });
-                            putItem({data:obj,id:itemId})
-
-                        }}>
-
-                            {itemId &&
+                    <form  onSubmit={this.props.changeItem}>
+                        {itemId &&
                             form.map(el => {
                                 el.required = false;
                                 return (
@@ -83,15 +81,17 @@ export default class ChangeServicesDoctors extends React.Component {
                                     />
                                 )
                             })
-                            }
-                            <input
-                                className = "btn link"
-                                type='submit'
-                                value='Изменить выбранный элемент'
-                            />
-                        </form>
+                        }
+                        <input
+                            className = "btn link"
+                            type='submit'
+                            value='Изменить выбранный элемент'
+                        />
+                    </form>
+                    {itemId &&
+                    <button className = "btn link" onClick={this.deleteItem} style={{backgroundColor:"#ff9774"}}>Удалить выбранный элемент</button>
                     }
-               </div>
+                </div>
             </div>
         );
     }

+ 64 - 14
src/components/Reviews.js

@@ -2,24 +2,74 @@ import React from 'react';
 // import {Link} from 'react-router-dom';
 // import Button from "../buttons/button";
 // import { postServices} from "../../store/app/actions";
+import {connect} from 'react-redux'
+import {
+    changeInputValueDoctorForm,
+} from "../actions/actions";
 
 
 
-
-export default class Reviews extends React.Component {
+export class Reviews extends React.Component {
     render( ) {
-        // const {postDoctors } = this.props
-        
+        const {postNewDoctor,doctors,servicesArray} = this.props.app
+        const servArray =  Object.keys(servicesArray).map(key => {
+            return [key, servicesArray[key]];
+        })
+        let doctor
+        if (doctors[0]) {
+            doctor = doctors[2].speciality
+        }
+        console.log(doctor)
+        console.log(servArray)
+
         return (
-            <div className = "main">
-                <div className="info-wrap">
-                                    <h2>Отзывы</h2>
-                <div classdescription = "reviews-container">
-                        ЗДЕСЬ БУДУТ ОТЗЫВЫ ПОСЕТИТЕЛЕЙ
-                 </div>
-                </div>
-
-            </div>
+           <div style={{display:'flex',margin:'100px 5px'}}>
+               {doctor &&
+                   servArray.map(el => (
+                       <div key={[el[0]]}>
+                           <p>{el[0]}</p>
+
+                            {
+                                el[1].map(item => (
+                                    <div key={item._id} style={{display:'flex',margin:'5px 5px',flexDirection:'column',width:'200px'}}>
+                                        <label >
+                                            <input
+                                                type="checkbox"
+                                                value={item._id}
+                                                defaultChecked={doctor.find(spec => spec._id === item._id)}
+                                            />
+                                            {item.name}
+                                        </label>
+                                    </div>
+                                ))
+                            }
+
+                       </div>
+                   ))
+               }
+           </div>
         ) 
     }
-}        
+}
+
+const mapStateToProps = state => {
+    return {
+        app:state.app,
+    }
+};
+
+const mapDispatchToProps = {
+    changeInputValueDoctorForm,
+};
+
+export default connect (mapStateToProps,mapDispatchToProps)(Reviews)
+
+// <div className = "main">
+//     <div className="info-wrap">
+//     <h2>Отзывы</h2>
+// <div classdescription = "reviews-container">
+//     ЗДЕСЬ БУДУТ ОТЗЫВЫ ПОСЕТИТЕЛЕЙ
+// </div>
+// </div>
+//
+// </div>

+ 2 - 2
src/components/appointment/Appointment.js

@@ -76,8 +76,8 @@ export class Appoint extends React.Component {
                                 {appointment.shedule &&
                                 <div>
                                     <div>
-                                        <select className = "appointment" onChange={(e)=>setAppointmentTime(e.target.value)} defaultValue='choose time'>
-                                            <option disabled >Выбор даты</option>
+                                        <select className = "appointment" onChange={(e)=>setAppointmentTime(e.target.value)} defaultValue='Выбор времени'>
+                                            <option disabled >Выбор времени</option>
                                             {
                                                 timeArray.map(el=> (
                                                     <option key={Object.keys(el)[0]}> {Object.keys(el)[0]} </option>

+ 1 - 1
src/reducers/auth.js

@@ -1,7 +1,7 @@
 import * as types from '../actionsTypes/actionsTypes'
 
 const initialState = {
-    user: {},
+    user:{},
     isFetching: false,
     error:null,
     successRegister: null

+ 14 - 16
src/reducers/reducers.js

@@ -7,12 +7,12 @@ const defaultState = {
     doctors:[],
     services:[],
     servicesArray:{
-        surgery:[],
-        kids:[],
-        orthodontics:[],
-        therapy:[],
-        implantology: [],
-        endodontics:[]
+        'Хирургия':[],
+        'Детская стоматология':[],
+        'Ортодонтия':[],
+        'Терапия':[],
+        'Имплантология': [],
+        'Эндодонтия':[]
     },
 
     orders:[],
@@ -39,7 +39,6 @@ const defaultState = {
     },
 
     timeArray:[],
-    wrongDate:true,
     isFetching:false,
     error: null,
 
@@ -132,8 +131,7 @@ export const appReducer = (state = defaultState,action) => {
                     ...state.appointment,
                     shedule:shedule._id
                 },
-                timeArray:timeArray,
-                wrongDate: action.payload
+                timeArray:timeArray
             };
         }
 
@@ -253,7 +251,7 @@ export const appReducer = (state = defaultState,action) => {
                                 ...state,
                                 servicesArray:{
                                     ...state.servicesArray,
-                                    orthodontics:state.servicesArray.orthodontics.push(el)
+                                    'Ортодонтия':state.servicesArray['Ортодонтия'].push(el)
                                 }
                             }
                         }
@@ -262,7 +260,7 @@ export const appReducer = (state = defaultState,action) => {
                                 ...state,
                                 servicesArray:{
                                     ...state.servicesArray,
-                                    kids:state.servicesArray.kids.push(el)
+                                    'Детская стоматология':state.servicesArray['Детская стоматология'].push(el)
                                 }
                             }
                         }
@@ -271,7 +269,7 @@ export const appReducer = (state = defaultState,action) => {
                                 ...state,
                                 servicesArray:{
                                     ...state.servicesArray,
-                                    implantology:state.servicesArray.implantology.push(el)
+                                    'Имплантология':state.servicesArray['Имплантология'].push(el)
                                 }
                             }
                         }
@@ -280,7 +278,7 @@ export const appReducer = (state = defaultState,action) => {
                                 ...state,
                                 servicesArray:{
                                     ...state.servicesArray,
-                                    implantology:state.servicesArray.implantology.push(el)
+                                    'Имплантология':state.servicesArray['Имплантология'].push(el)
                                 }
                             }
                         }
@@ -289,7 +287,7 @@ export const appReducer = (state = defaultState,action) => {
                                 ...state,
                                 servicesArray:{
                                     ...state.servicesArray,
-                                    surgery:state.servicesArray.surgery.push(el)
+                                    'Хирургия':state.servicesArray['Хирургия'].push(el)
                                 }
                             }
                         }
@@ -298,7 +296,7 @@ export const appReducer = (state = defaultState,action) => {
                                 ...state,
                                 servicesArray:{
                                     ...state.servicesArray,
-                                    endodontics:state.servicesArray.endodontics.push(el)
+                                    'Эндодонтия':state.servicesArray['Эндодонтия'].push(el)
                                 }
                             }
                         }
@@ -307,7 +305,7 @@ export const appReducer = (state = defaultState,action) => {
                                 ...state,
                                 servicesArray:{
                                     ...state.servicesArray,
-                                    therapy:state.servicesArray.therapy.push(el)
+                                    'Терапия':state.servicesArray['Терапия'].push(el)
                                 }
                             }
                         }